[cache-bundle] Additional Content-Types to cache-bundle.json
API
- Cache any content types other than
text/html, text/javascript, image/svg+xml
- Optional headers to include in cache response headers
hook.parameters.significantHeaders = { "Header-Name": true }
- Additional Cacheable Content-Types
hook.parameters.cacheableContentTypes = { "text/css": true, "image/png": true, ... }
- Note:
text/html, text/javascript, image/svg+xml must not be included here
- Callback to Validate Cacheable URL
hook.parameters.validateCacheableUrl = function (url, contentType)
url: String: target URL to validate
contentType: String: normalized Content-Type without charset
- return a truthy value if
url with contentType is cacheable
- If the callback function is undefined, any
contentType values within hook.parameters.cacheableContentTypes are cacheable
- Extended Metadata Format in
cache-bundle.json
cacheBundle = {
"version": "version_123", // cache version
"url?param=1": "body in string", // concise format for string data for .js, .html, .json, .svg; equivalent to { "body": "body in string", "Content-Type": "{type}" }
"url?param=2": {
"Location": "url?param=1", // link to the other content
"Location": "data:image/jpeg;base64,...", // encoded body data; Note: "Location" appears only once in a metadata object, of course
// If Non-dataURI "Location" exists, other metadata entries are ignored
"Content-Type": "text/xml", // MIME type
"body": "body in string", // content body
"Other-Headers": "header value", // HTTP headers
},
}
[cache-bundle] Additional Content-Types to
cache-bundle.jsonAPI
text/html,text/javascript,image/svg+xmlhook.parameters.significantHeaders = { "Header-Name": true }hook.parameters.cacheableContentTypes = { "text/css": true, "image/png": true, ... }text/html,text/javascript,image/svg+xmlmust not be included herehook.parameters.validateCacheableUrl = function (url, contentType)url: String: target URL to validatecontentType: String: normalized Content-Type without charseturlwithcontentTypeis cacheablecontentTypevalues withinhook.parameters.cacheableContentTypesare cacheablecache-bundle.json