July 2018
Intermediate to advanced
354 pages
8h 51m
English
A more complex technique I have used to manage service worker caches is the manifest file. This technique involves maintaining a file with a JSON object with caching rules:
[{
"url": "/",
"strategy": "precache-dependency",
"ttl": 604800
}, {
"url": "/privacy",
"strategy": "genericFallback",
"fallback": "fallback/",
"ttl": 604800
}, {
"url": "/product/*",
"strategy": "cacheFirst",
"ttl": 1800
},
...
]
To leverage this technique, you would process the dynamic requests by testing their URL against the supplied routes. This can be done using a regular expression.
This process is very similar to the way the routes and caching strategies were defined and triggered earlier. The request URL is tested against a regular ...
Read now
Unlock full access