How should I structure my HTML5 manifest given these requirements?

╄→гoц情女王★ 提交于 2019-12-10 21:33:03

问题


I have a HTML jquerymobile App, I need to show an offline page when the user tries to load the app from their home screen.

The page I want them to see is gone-offline.jsp. Problem is, if I include the HTML manifest on every page the user visits, that page ends up getting cached, which means when the user loads the app offline, they sometimes see the page they visited but images are missing etc, I do not want that, I want a clean caching system that only caches a certain page.

Is it possible to prevent the other pages getting cached when user visits them.

What I'd like is to just cache a little JS file which checks if navigator online, if not redirects to that gone-offline page..


回答1:


See this question which helps:

In summary, use a manifest which looks like this:

CACHE MANIFEST
CACHE:
/gone-offline.jsp

FALLBACK:
/ /gone-offline.jsp

NETWORK:
*



回答2:


A manifest can have three distinct sections: CACHE, NETWORK, and FALLBACK.

CACHE: This is the default section for entries. Files listed under this header (or immediately after the CACHE MANIFEST) will be explicitly cached after they're downloaded for the first time.

NETWORK: Files listed under this section are white-listed resources that require a connection to the server. All requests to these resources bypass the cache, even if the user is offline. Wildcards may be used.

FALLBACK: An optional section specifying fallback pages if a resource is inaccessible. The first URI is the resource, the second is the fallback. Both URIs must be relative and from the same origin as the manifest file. Wildcards may be used. Note: These sections can be listed in any order and each section can appear more than one in a single manifest.

source: http://www.html5rocks.com/en/tutorials/appcache/beginner/

I'm not very familiar with HTML5 cache manifests but it looks like you want to use the NETWORK section to force some pages to refresh regardless of connection state.



来源:https://stackoverflow.com/questions/9422846/how-should-i-structure-my-html5-manifest-given-these-requirements

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