Playing with AppCache for offline page access
Some links to useful resources:
- http://www.html5rocks.com/en/tutorials/appcache/beginner/
- http://www.deluxeblogtips.com/2010/06/htaccess-rules-website-performace.html
- How to use
Expires
in your headers/.htaccess file to ensure the browser regularly checks the manifest
- How to use
- http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html
- https://developer.mozilla.org/en-US/docs/Web/HTML/Using_the_application_cache
- Remember your appcache file needs the text/appcache mimetype
AddType text/cache-manifest .appcache
in Apache
htaccess additions
Here are my .htaccess
file additions for the directory which is utilizing appcache (http://sagar.org/qrc/):
. . . AddType text/cache-manifest .appcache ExpiresActive On ExpiresByType text/cache-manifest "access plus 0 seconds"
Adding an appcache manifest
The manifest file tells the browser which resources from the site to cache locally. The manifest is referenced via an attribute in the landing page's <html ... >
tag.
Remember: the appcache must be of content-type text/appcache
.
NOTE: unless the manifest changes, none of the referenced files will ever again be fetched from the server. That's the sole purpose of the comment line (see that "#
" means comment) in the manifest. I can change it when I want to invalidate a browsers downloaded version of the website/webapp. Only when the manifest is modified will it's contents be re-examined and (if necessary) re-downloaded.
CACHE MANIFEST # 2014-05-30 v0.1 CACHE: /qrc/index.html /qrc/sagarorg_qrc.png FALLBACK: /qrc/ /qrc/index.html