Proposed extensions to application cache
(Originally published in 2011.)
Extensions to the application cache itself
These would allow the page to exclude resources that would ordinarily be included due to a wildcard.
Precedence is up for debate. There are basically three choices:
- Exclusions are always higher precedence than inclusions
- Respect order of declaration
- Respect specificity, similar to how CSS determines precedence
I personally favour #1, because simple rules are easier to work with and remember.
Proposed syntax: prefix lines with a minus followed by a space (
CACHE MANIFEST /style.css /resources/* - /resources/uncached/*
Making HTML caching optional
This is intended to facilitate the use case of speeding up online applications, allowing non-blocking updates of important but non-critical resources.
Proposed syntax: leverage manifest exclusions to simply exclude the path to the current page. For example, if www.example.com/index.html was appcached, the manifest might include this:
CACHE MANIFEST /style.css /resources/* - /index.html
Automatically expire and refresh cached data
There are some use cases where it would be nice to refresh the appcached data prior to rendering the page (if the browser was currently online, of course). One obvious example is if a security vulnerability is fixed in the latest version of a page.
Proposed syntax: a
MIN_TIMESTAMP value in the manifest would indicate that we want to check the manifest prior to rendering the page when possible. If the previously cached data is older than the current minimum timestamp, discard it and act as if we have no cached data.
CACHE MANIFEST /style.css /resources/* MIN_TIMESTAMP 1320451230
There are some use cases where the contents of the manifest may vary based on how much disk space is available — for example, using a set of higher resolution images if the client has the capacity for them.
I suggest adding at least two of the following headers to HTTP requests for the manifest file:
X-Cache-Quota-Available X-Cache-Quota-Total X-Cache-Quota-Used
These would indicate the number of bytes available/total/used.
There is currently no way to clear the current page’s appcached data (although it’s possible to trigger an expiry with the aid of a server and a clever endpoint).
Calling this method should remove all appcached data for the current page:
When this is complete, it should fire an event (
cleared) and set
There is currently no way to determine how much space is available for appcached data. I suggest adding at least two of the following values:
// total number of bytes available for this page's application cache applicationCache.quota.total // number of bytes currently used for this page's application cache applicationCache.quota.used // remaining number of bytes available for this page's application cache applicationCache.quota.available