sw-delta icon indicating copy to clipboard operation
sw-delta copied to clipboard

You can "modify" entries in the cache api

Open jakearchibald opened this issue 9 years ago • 5 comments

caches.open(name)
  .then(c => c.put("/", new Response("lololol")));

In cache storage, the requests & responses can be mismatched in terms of their original fetching, or either/both can be of your own making.

jakearchibald avatar Aug 14 '16 04:08 jakearchibald

Oh great! I don't understand how I missed that.

I'll make this change, but now I need to find a way to store the version number. IndexedDB was interesting for this!

gmetais avatar Aug 14 '16 05:08 gmetais

You could put metadata in headers, but it could be that indexeddb is a better fit.

jakearchibald avatar Aug 14 '16 05:08 jakearchibald

I like the idea of storing the info inside the headers. A unique request to Cache is better than 2 requests to Cache + IDB.

gmetais avatar Aug 14 '16 05:08 gmetais

It may be good to update the part of the readme that talks about IDB to mention this https://github.com/gmetais/sw-delta#why-does-sw-delta-use-indexeddb-instead-of-the-cache-api-in-its-service-worker

Maybe just referencing this issue to say it's a possible work-in-progress. Otherwise folks may get the wrong idea about how the Cache API works

robdodson avatar Aug 14 '16 15:08 robdodson

Maybe just referencing this issue to say it's a possible work-in-progress.

Done.

gmetais avatar Aug 15 '16 11:08 gmetais