Question

We are using a "manifest.appcache" file to control the application cache on our site. A part of the application should be accessible offline, which means that some of the pages have the reference on the manifest in the html-tag, others don't.

Is there any way to check if the cache is empty (from all pages)?

Example Page A is available online only, so no manifest is referenced. Page B is available online and offline, so the manifest is referenced. Now we want to check on page A (online only) if page B is already cached (the cache is not empty).

Was it helpful?

Solution

There is no way to check if the cache is empty or if there is an page in the cache (with application cache).

If you really need to do it, there are two solutions you can use:

  1. You can use cookies to track the sites that are loaded in the cache. This opens new problems: What if the user clears the cookies and not the application cache?

  2. The more cleaner solution is to use IndexedDB or the HTML5 FileSystem to save the content and just cache wrappers for that content. You can cache the wrappers to the beginning and then you can handle the content with the APIs i mentioned (i used this one). This way you can simply check whether a page is in the cache or not.

Sorry for answering my own question, but i hope this saves some time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top