dojo 和离线应用程序缓存

发布于 2024-10-30 19:01:59 字数 285 浏览 6 评论 0原文

我们一直致力于使用 Dojo 以及较新浏览器中提供的存储和离线功能来开发具有离线功能的 JavaScript 应用程序。

该应用程序非常大,但似乎从缓存加载较大的文件,并且我可以看到该应用程序确实已缓存。我们正在使用应用程序缓存功能,据我和 Chrome 观察,应用程序缓存中没有任何错误。

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

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

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

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

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.

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

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

Any ideas to what might be wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

dawn曙光 2024-11-06 19:01:59

当您离线使用(最有可能是移动设备)时,大多数时候您还需要优化的构建。您确实不想使几十个文件脱机。

我不认为 XHR 可以离线工作,因此您通过 XHR 加载的任何资源(包括脚本、i18n 捆绑包和其他通过 href 触发的动态加载资源)都应该存储到 localStorage 中,然后分支到从 loaclStorage 加载离线时的 XHR。

现在,如果您在 iPhone、iPad 或 Android 设备上运行,您确实需要进行优化构建。还可以考虑使用闭包编译器来进一步优化您的构建。请参阅下面的链接。

http://dojo-toolkit.33424 .n3.nabble.com/file/n2636749/Using_the_Dojo_Toolkit_with_the_Closure_Compiler.pdf?by-user=t

When you use off-line, (most likely mobile), most of the time you'll need an optimized build as well. You don't really want to offline a few dozen files.

I don't think XHR works offline, so any resource you load via XHR (that includes scripts, i18n bundles and other dynamically-loaded resources that are triggered via href) you should store into localStorage, and then branch off to load from loaclStorage instead of XHR when offline.

Now, you really need to be making an optimized build if you are running on the iPhone, iPad or an Android device. Also consider using the Closure Compiler to further optimize your build. See link below.

http://dojo-toolkit.33424.n3.nabble.com/file/n2636749/Using_the_Dojo_Toolkit_with_the_Closure_Compiler.pdf?by-user=t

甜点 2024-11-06 19:01:59

问题是 dojo 执行了一些初始化 XHR 请求。它会上网获取其本地化包和 RPC 功能的任何 .smd 文件。

XHR 无法访问离线 applicationCache,即使捆绑包和 smd 文件在那里可用,当 Dojo 请求它们时,它们也不会被找到。

另一种方法是将它们保留在清单文件之外,但这意味着 dojo 无论如何都不会脱机启动。

我们通过将位于 .smd 文件中的服务规范对象直接添加到 dojo.rpc.Service 的构造函数来修复 .smd 文件的问题。这意味着道场拥有所需的一切,不再需要去取。

本地化包是不同的。最后,我确保将它们附加到 dojo.js 的末尾,让 dojo.provide 语句处理其余的事情。本质上,我修改了构建脚本(我们的一个bat文件),在构建后将压缩的本地化包放在dojo.js的末尾。

现在dojo可以离线启动了。

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 cannot access the offline applicationCache, even though the bundle and smd files are avaliable there they wont be found when Dojo asks for them.

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

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.

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.

Now dojo can start offline.

云朵有点甜 2024-11-06 19:01:59

您是否正在使用 HTML5 应用程序缓存 的清单文件?如果是这样,您需要显式列出要缓存的文件和目录。与所有其他资源一样,您构建的本地化包必须在清单中说明,无论是在 CACHE 部分还是在 NETWORK 部分

Are you using a manifest file for an HTML5 application cache? If so, you need to explicitly list files and directories to cache. Like all other resources, your built localization bundles must be accounted for in your manifest, either in the CACHE section or in the NETWORK section

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文