User Tools

Site Tools


nfldb_m2

This is an old revision of the document!


get web first then cache self.addEventListener('fetch', (event) ⇒ {

event.respondWith(
  fetch(event.request)
    .then((networkResponse) => {
      // Clone the response before caching (it can only be read once)
      return caches.open('dynamic-cache').then((cache) => {
        cache.put(event.request, networkResponse.clone());
        return networkResponse;
      });
    })
    .catch(() => {
      // Fallback to cache if the network request fails (offline)
      return caches.match(event.request);
    })
);

});

nfldb_m2.1780235740.txt.gz · Last modified: 2026/05/31 13:55 by admin