iPhone 和 HTML5 缓存清单

发布于 2024-07-08 17:53:20 字数 556 浏览 13 评论 0 原文

我正在尝试使用 ASP.NET 构建 iPhone Web 应用程序。 该页面为每个访问者动态呈现一次。 此时,该页面可以被添加书签,并且对于该访问者而言,该页面将永远不会再次更改。 因此,从那时起,它应该在本地缓存,这样即使没有可用的网络连接,如果从书签引用应用程序也会运行。 无论我尝试什么,手机都会继续从服务器请求页面,强制重新渲染,否则如果手机离线,则会失败。

Louis Gerbarg这篇文章,我使用 HTML5 缓存清单来使其正常工作,但是遵循 w3.org 文档 似乎不适用于 iPhone。 有谁有应用程序缓存工作的好例子吗?

I am trying to build an iPhone web application using ASP.NET. The page is dynamically rendered once for each visitor. At this point the page can be bookmarked and it will never change again for that visitor. For this reason it should be cached locally from that point on so the application will run if referenced from the bookmark even if no network connection is available. No matter what I try the phone continues to request the page from the server forcing a re-render or it fails if the phone is offline.

Louis Gerbarg suggested in this post that I use HTML5 Cache Manifest to get this working however following the w3.org docs does not appear to work for the iPhone. Does anyone have a good example where application cache is working?

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

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

发布评论

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

评论(4

真心难拥有 2024-07-15 17:53:21

缓存清单文件必须使用“text/cache-manifest”mime 类型提供。 这绝对是至关重要的,没有它就无法工作。 如果您导航到清单文件的 url,它应该会触发下载...

另外,我发现将清单位置作为绝对位置放入标签中,以及清单文件中的所有条目更加有效。

The cache manifest file has to be served with a 'text/cache-manifest' mime-type. This is absolutely critical, it will not work without it. If you navigate to the url of your manifest file, it should trigger a download...

Also, I've found that putting the manifest location in the tag as an absolute location, as well as all the entries in the manifest file to be more effective.

相权↑美人 2024-07-15 17:53:21

我回答了您之前与此相关的问题,但从该问题中不清楚您是否正在尝试缓存动态内容。 缓存清单用于获取离线 Web 应用程序运行所需的静态内容。

我不确定你能做你想做的事。 您是否希望应用程序能够离线运行,或者您只是想将某些内容固定在缓存中,因为下载速度很慢? 除非您实际上正在构建一个离线 Web 应用程序(用户将其作为书签或 Spring Board 中的应用程序添加到其中),否则您的页面可以(并且必须)由浏览器自行决定从本地存储中逐出,无论内容有多松散。您在页面上设置的缓存策略。

I answered your previous question related to this, but it was not clear from that question that you were trying to cache dynamic content. The cache manifest is for getting static content you want for offline web apps to work.

I am not sure you can do what you want. Do you want the app to be able to function offline, or are you just trying to peg something in the cache because it is slow to download? Unless you are actually constructing an offline webapp (which the user will add to as a bookmark or an app in the Spring Board) then your page can (and must necessarily) be evicted from local storage at the browsers discretion, regardless of how loose a cache policy you set on the page.

疑心病 2024-07-15 17:53:21

您应该使用适用于 iPhone 和 Safari 3.1 的 Safari Javascript 数据库 API。 它非常适合本地缓存和数据存储:

http://developer.apple.com /documentation/iPhone/Conceptual/SafariJSDatabaseGuide/

You should use the Safari Javascript Database API which should work for iPhone and Safari 3.1. It works great for local caching and data storage:

http://developer.apple.com/documentation/iPhone/Conceptual/SafariJSDatabaseGuide/

烈酒灼喉 2024-07-15 17:53:21

这可能与输出的大小有关。

我无法谈论专门针对 iphone 进行调整的任何认真经验,但 YUI 团队在此阅读了一篇有趣的文章: http://yuiblog.com/blog/2008/02/06/iphone-cacheability/,表示解压后所能容纳的最大缓存文件iPhone 为 25k,为了获得最佳缓存,尽可能多的组件应小于 25k。

这可能是导致您出现问题的原因,但这只是猜测。

It could be to do with the size of the output.

I can't talk from any serious experience in tweaking things specifically for an iphone, but there is an intersting read from the YUI team here: http://yuiblog.com/blog/2008/02/06/iphone-cacheability/, which indicates that the largest unzipped cache file that can be held in an iphone is 25k, and that for optimal caching, as many components as possible should be <25k.

That may be the cause of your problems, but that's only a guess.

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