fetch(url).then((response) => {
if (!response.ok) {
throw new TypeError("bad response status");
}
return cache.put(url, response);
});Cache: add() method / notebook
Cache: add() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
this.addEventListener("install", (event) => {
event.waitUntil(caches.open("v1").then((cache) => cache.add("/index.html")));
});