在缓存清单文件HTML5的FALLBACK部分使用通配符 [英] Using Wildcard in FALLBACK section of Cache manifest file HTML5

查看:115
本文介绍了在缓存清单文件HTML5的FALLBACK部分使用通配符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建启用离线功能的网络应用程序,以便当用户访问hxxp:// mywebsite /并且显示为hxxp:// mywebsite / offline /时离线为
。 [我的网站上有大约100个不同的动态页面,因此我无法在缓存清单文件中对所有这些页面进行硬编码]

How to create an offline enabled web-application such that when user visits hxxp://mywebsite/ and is offline than hxxp://mywebsite/offline/ is displayed. [There are about 100 different dynamic pages in my website, so I cannot afford to hardcode all of them in the cache manifest file]

推荐答案

CACHE MANIFEST
CACHE:
/Offline/OfflineIndex.html

FALLBACK:
/ /Offline/OfflineIndex.html

NETWORK:
*

这将导致您的所有页面在整个网站上脱机时重定向到离线。唯一的问题是声明清单的页面,因为该页面总是被缓存。这意味着您无法在每个页面上声明清单,因为每个访问过的页面都将自行缓存并且不会重定向。因此,您可以做的是在另一个html文件(IE。Synchronize.html)上声明您的清单,然后从默认情况下通过存储cookie或localcache值来检查您的应用程序是否可用于脱机。如果没有重定向到synchronize.html与声明的清单,设置localcache值,并重定向回索引。

This will cause all your pages across the entire site to redirect to offline when offline. The only issue is with the page that declares the manifest as that page is always cached. This means you cannot declare the manifest on every page because every visited page will then be cached itself and not redirect. So what you can do is declare your manifest on another html file (IE. Synchronize.html) then from default check whether or not your app has been made available for offline by storing a cookie or localcache value. If not redirect to synchronize.html with the manifest declared, set the localcache value, and redirect back to index.

OFFLINE AWESOMENESSSSSSSSSSS !!!!

OFFLINE AWESOMENESSSSSSSSSSS!!!!

这篇关于在缓存清单文件HTML5的FALLBACK部分使用通配符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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