HTML5仅在脱机时使用缓存 [英] HTML5 use cache only when offline

查看:124
本文介绍了HTML5仅在脱机时使用缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用 HTML5缓存来查看包含一个css文件和两个js文件的简单HTML页面。

I started to use HTML5 cache to view a simple HTML page with one css file and two js files.

我的问题是无论我是否离线,都会使用缓存。但我只想在我离线时使用缓存
有谁知道如何解决这个问题?

My problem is that the cache is used whether I'm offline or not. But I just want to use the cache when I'm offline. Does anyone know how to solve this?

index.html 文件清单:

<html manifest="app.cache">

app.cache 清单文件:

CACHE MANIFEST
/index.html
/css/style.css
/js/jquery-1.7.1.min.js
/js/functions.min.js

谢谢!

推荐答案

manifest =app.cache - 不会解决您的问题。它缓存清单文件中列出的所有文件。您必须将数据保存在本地存储或本地数据库中,并且必须根据连接状态[在线/离线]从服务器/本地检索数据。

manifest="app.cache" - not going to solve your problem. It caches all the file listed in manifest file. You have to save your data in local storage or in local db and have to retrieve data from server/local based on connection status [online/offline].

这篇关于HTML5仅在脱机时使用缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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