4

HTML 5 offline logic is encapsulated in window.applicationCache object. However it looks like it's not possible to programmatically clear cache data, for example, when user logs off from the system. Is there any other way to clear HTML 5 application cache, except for generating empty manifest file?

Konstantin
  • 3,817
  • 4
  • 29
  • 39
  • Its also important to note that even showing empty manifest file to the browser will only remove "explicit" entries from the cache. "Master" entries (html documents with "manifest" attribute) will be left. So in order to clear the cache, one needs to have only a single "public" master html document with all other pages listed explicitly in the manifest file. – Konstantin Jul 12 '11 at 07:38

3 Answers3

5

Have observed this on Chrome not sure if that's the standard way, if server responds with 404 on manifest file request, cache gets cleared from browser after raising obsolete event.

programmer
  • 51
  • 1
  • 2
  • I've done it that way, setting the manifest to a non-existing file. That completely removes the cache. Although it is a workaround, it seems to be official as stated on http://appcachefacts.info/ `If the manifest file itself can't be retrieved, the cache will ignored and all cached data associated with it will be disregarded` – spuas Jun 06 '14 at 22:10
  • Not always - Chrome 37.0.2062.124 on MacOS, when the manifest url returns 403, the cache persists :| – Artur Bodera Oct 03 '14 at 08:38
3

Setting aside the specifics of the HTML5 appcache, clearing a browser's cache programmatically has never been possible (beyond certain ActiveX controls for that browser) so I suspect you may come up empty on this one. Perhaps you should focus on the cache control meta tag and test further with your empty manifest idea?

Ben
  • 7,548
  • 31
  • 45
0

I think the best way to do this is to change the link to the manifest file. In this case I would append the user's session ID to the manifest file. Every user should have session regardless of logged in status and the session ID should probably changed when logging in/out (maybe).

I also found this answer: Removing HTML5 Appcache Manifest, Permanently

Community
  • 1
  • 1
Parris
  • 17,833
  • 17
  • 90
  • 133