Manifest Builder 1.0 (for Code Igniter)
This class dynamically creates a manifest file that contains a list of the resources for the browser’s Application Cache. Using an Application Cache will speed up loading times and make the application available offline. Both HTML5 and Gears (deprecated) manifest formats are supported.
The builder is implemented as a fat controller to keep things simple (and I can’t think of a situation where you’d have more than 1 manifest in an application).
The following features are included:
- automatically detect all resources in link and img tags in html and add these to the manifest
- automatically detect all images files in the linked css stylesheets files and add these to the manifest
- automatic version number update when the manifest resources have changed (so client browser is prompted to re-download the resources)
- ability to manually update the version number (for troubleshooting and when edits may not result in changes in the dynamically created resources)
- ability to manually add additional pages to include, a fallback resource and resources that should never be cached
How to use
When using the Code Igniter’s PHP framework, the controller manifest.php can simply be copied into the application/controllers folder and the two views in the application/views folder. To test go to: yourdomain.com/manifest/html5 (or yourdomain.com/manifest/gears). If it works add the manifest url to your html tag(s). If another framework is used you’ll have to tweak/port the code (please create a fork, or become a collaborator of this project).
The commented block right after the class declaration allows customization of the manifest and includes:
- a forced version number update ($hash_manual_override) in case this is necessary
- adding additional cache resources ($pages), such as any pages in addition to the main page (index.php e.g.) which is already included (’’)
- the fallback page to load when an app is offline and gets a request for a page that does not exist in the Application Cache ($offline)
- any resources that should never be cached ($network)
Feedback welcome here