iPhone and HTML5 Cache Manifest

亡梦爱人 提交于 2019-12-03 04:01:20

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.

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.

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/

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.

If anyone is interested here is a simple demo of the app cache i built for proof of concept. You need to check what your browser supports but this works in FF 3.5 and Safari on the IPhone http://demos.hahana.co.uk/app-cache-demo.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!