Automatically generating an HTML5 cache manifest
Posted on Monday, September 26, 2011 @ 10:34 CET
When we were developing fotb.me we ensured the app would run offline using the fancy, new HTML5 app cache API. It can be a pain to create the cache manifest file by hand, this is obviously something that should be automated.
I looked around and found a plugin for Coda and a bundle for TextMate and TextWrangler which are good, but they don't allow me to ignore certain files and only add certain filetypes which were two things I needed. Not wanting to have to remember to edit the generated files manually I rolled our own.
CacheManifestGenerator is a simple Ruby script that traverses any folder recursively and makes a note of each file. You can add specific files to be ignored and the specific file extensions to look for. Very, very simple yet effective.
It also adds a comment with the time of creation. This is enough to trigger browsers to check the manifest contents as the file itself is different.
Oh and btw, Ruby is fun!
Update:
John Allsopp reminded me of manifestR, an online tool that creates a manifest for any page you are visiting via a bookmarklet. Very cool stuff, but it didn't work for us as the site has to be online, not be password protected (something we were avoiding pre-launch) and also the ignore files bit I mentioned above. However if you don't need those things then its definitely the easiest way of generating a manifest automatically.
- paulo


Hey Paulo. I just got a chance to upload the PHP version I mentioned on Twitter. It's not very generic but it should be useful to those using PHP.
http://www.richardleggett.co.uk/blog/index.php/2011/09/26/dynamic-application-cache-manifest-for-php
# September 26, 2011 21:34 CET
Post a comment:
You must have Flash and JavaScript enabled to post a comment.