How to clear Application cache (HTML5 feature) using JavaScript?

为君一笑 提交于 2019-12-05 09:39:43

The problem with the application cache taking up so much space is that you are giving the user agent a different offline web application each time. An offline web application is identified to the user agent by the URI of the cache manifest file, including query string - not the URI of the master file as you might think.

Thus, by including the session ID in the cache manifest URI, you're telling the browser that each session gets its own brand new application without using any of the previously downloaded ones (and thus, never being able to clear them out). You're installing a different web application every time.

Reconsider how you're architecting your application, as currently using HTML5 offline cache manifest is providing no value - just causing excessive downloading. The architecture that web applications encourage is serving all HTML statically, and fetching data that requires sessions via AJAX. Web applications don't work when built in the classic "dynamically generate an HTML page with data on the server" paradigm.

I'm not sure you do have control over application cache from JavaScript. This is something which should be handled by the browser and the user when clearing the cache.

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