HTML5离线应用
我正在尝试在单个 html 页面中应用 html5 离线应用程序。 Google、Jquery 或其他服务提供商是否有任何单行链接 API(例如我们使用 Google 地图链接)可以轻松启用离线缓存? 我是 html5 和 Javascript 新手,请帮助我。
多谢。
I am trying to apply html5 offline application in a single html page.
Is there any one line link API(like we use Google map link) by Google, Jquery or some other service provider which can easily enable offline cache?
I am new to html5 and Javascript please help me out.
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这并不像单链接包含那么容易。至少,您需要一个清单文件。该文件告诉您的应用程序应缓存哪些文件。您可以在此处了解更多信息。以下是清单文件内容的示例:
清单内容
您还可以阅读这个关于清单/离线应用程序的非常好的教程,这里。
准备好清单文件后,您可以使用以下代码来测试您的清单以及缓存和未缓存的内容、已缓存的内容等。
调试代码:
希望这会有所帮助。
It's not really as easy as a one-link inclusion. At bare minimum, you need a manifest file. This file tells your application what files should be cached. You can read more on that here. Here is a sample of a manifest files contents:
Manifest content
You can also read this pretty good tutorial on manifest/offline applications, here.
Once you have a manifest file in place, you can use the following code to test your manifest and what is and isn't caching, cached, etc..
Debug code:
Hope this helps.
一般来说,html5 离线功能是通过创建一个清单文件来启用的,该清单文件描述了浏览器应缓存应用程序中的哪些资源。
阅读此
http://www.webreference.com/authoring/languages/ html/HTML5-Application-Caching/
以及一般谷歌搜索“html5 清单”。
我不知道单页应用程序会受益多少;您的应用程序需要能够离线运行才能获得好处。例如,电子邮件 RIA 可能允许您离线撰写消息,并将其存储在本地存储中,直到您在线并可以发送消息。同样,它可能会在在线时加载并存储您的电子邮件,以便您可以在离线时查看您的消息......
in general the html5 offline capabilities are enabled by creating a manifest file that describes what resource in your app should be cached by the browser.
Read this
http://www.webreference.com/authoring/languages/html/HTML5-Application-Caching/
and also general google search for 'html5 manifest'.
I don't know how much benefit a one page application will benefit; your app needs to be able to function offline to gain a benefit. So for example, an email RIA might allow you to compose a message offline, and would store it in local storage until you are online and could send the message. similarly, it might load and store your emails when online so you could review your messages while offline...