dojo和脱机应用程序缓存 [英] dojo and the offline application cache

查看:90
本文介绍了dojo和脱机应用程序缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们一直在使用Dojo开发具有脱机功能的JavaScript应用程序,以及新浏览器中可用的存储和脱机功能.

We've been working on an offline capable JavaScript applicaion using Dojo and the storage and offline capabilities available in newer browsers.

该应用程序非常大,但是它似乎从缓存中加载了较大的文件,并且我可以看到该应用程序确实在缓存中.据我和Chrome所见,正在使用applicationcache功能,并且应用程序缓存中没有错误.

The application is quite large, but it seems to load the larger files from the cache, and I can see that the application is in deed cached. Were using the applicationcache features, and there are no errors in the application cache as far as I and Chrome can see.

但是我们遇到了问题.显然,Dojo无法加载其语言资源,也无法加载描述我们连接到的服务的SMD文件.

However we run into problems. Apparently Dojo cannot load its lanugage resources, nor the SMD file that describes the service we connect to.

这些问题在目标浏览器webkit-mobile上非常明显.

These problems are highly visible on webkit-mobile, which is the targeted browser.

有什么想法可能有什么问题吗?

Any ideas to what might be wrong?

推荐答案

问题是dojo做了一些初始化的XHR请求.它可以联机获取本地化包和RPC功能的任何.smd文件.

The issue is that dojo does a few initalization XHR Requests. It goes online to fetch its localization bundle and any .smd files for the RPC feature.

XHR无法访问脱机applicationCache,即使bundle和smd文件可用,在Dojo要求时也找不到它们.

XHR cannot access the offline applicationCache, even though the bundle and smd files are avaliable there they wont be found when Dojo asks for them.

另一种选择是将它们保留在清单文件之外,但这意味着dojo始终不会脱机启动.

An alternative is to leave them outside the manifest file, but that means dojo wont start offline anyway.

通过将位于.smd文件中的服务规范对象直接添加到dojo.rpc.Service的构造函数中,我们解决了.smd文件的问题.这意味着dojo拥有了所有需要的东西,而不再需要获取它.

We fixed the issue with the .smd file by adding the service specification object located in the .smd file directly to the constructor of dojo.rpc.Service. This meant that dojo had all it needed and no longer had to fetch it.

本地化包是不同的.最后,我确保将它们附加到dojo.js的末尾,让dojo.provide语句负责其余部分.本质上,我将构建脚本(对我们来说是一个bat文件)修改为在构建后将压缩后的本地化包放在dojo.js的末尾.

The localization bundles was different. In the end I made sure that they were appended to the end of dojo.js, letting the dojo.provide statements take care of the rest. In essence I modified the build script (a bat file for us) to after building put the compacted localization bundle at the end of dojo.js.

现在dojo可以离线启动.

Now dojo can start offline.

这篇关于dojo和脱机应用程序缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆