Reputation: 223
I created a webapp which should always use the most current files and don't cache anything. BUT when the client goes offline, it should present the "offline.html" which continuously tries to load the "index.php" every 30sec.
Here is the thing: my index.php gets also cached because it has the manifest tag. But this messes up the functionality of my webapp.
So I wanted to ask, what are the best solutions to use the cache manifest only for providing a fallback, not for caching anything else?
index.php
<html manifest="/cache.manifest">
cache.manifest
CACHE MANIFEST
FALLBACK:
/ /offline.html
NETWORK:
*
I've found this solution here https://stackoverflow.com/a/19974768/1311566 where the guy uses an iframe to load an html with the manifest tag in it so that the index.php doesn't get cached. But I wanted to know if there are any other, or maybe even better, solutions out there.
Many thanks in advance, Stefan
Upvotes: 1
Views: 596
Reputation: 2385
The solution described at https://stackoverflow.com/a/19974768/1311566 is correct. It's the only way to prevent the HTML files from being cached and only fallback to /offline.html
if requests fail.
I build offline-compatible apps based on applicationCache since 3+ years now, and trust me this is the only way. If you like to have a nice JS API for the iframe Hack (and much more), you can use a library I've build: https://github.com/gr2m/appcache-nanny
By the way this iframe hack has been invented by the Financial Times Labs team, they put together a great tutorial with lots of background information on it: http://labs.ft.com/category/tutorial/
Upvotes: 2