开发者

Preload pages to cache them using html5 manifest ajax

开发者 https://www.devze.com 2023-03-07 05:55 出处:网络
I\'m currently having a situation where I have online courses website. But I want it to be accessible locally offline. I added a manifest for all topics in the courses. And if they are visited, they a

I'm currently having a situation where I have online courses website. But I want it to be accessible locally offline. I added a manifest for all topics in the courses. And if they are visited, they are cached locally.

However, I now want to add a button "Make offline available" to preload all these pages without having to visit them first manually.

I tried loading all these files by multiple ajax-calls triggered by the button. They would $.get() the page, and I was hoping that the browser would cache开发者_JAVA技巧 them. However, it does not seem to work. It seems that the browser doesn't interpret pages it doesn't show...

Is there a way for doing this by using javascript and manifests?

Thanks!


Manifests don't really work the way you want, I believe. The entries in your manifest file will be cached in the background. The user never has to visit the page for it to be cached.

Here's a great resource for html5 manifests: http://diveintohtml5.ep.io/offline.html


you can send ajax requests and pre fetch the page contents and save them in hidden divs. you can write handlers for events triggering page navigation and show the corresponding divs when requested.


Yes it is. But all requests for resources in manifest-file does not have any parameters, p.e.:

CACHE MANIFEST

CACHE:
/cgi-bin/imgrequest.cgi     # OK
/cgi-bin/request.cgi?id=123 # Wrong, it does not work
0

精彩评论

暂无评论...
验证码 换一张
取 消