I'm wanting to invalidate a previously cached GET from my service worker when a POST, PUT, or DELETE to the same url or any url of a resource or collection 'under' it happens, for example:
let's say I cache /subscriptions and later on I do a POST to /subscriptions to add a new subscription, or say I PUT to /subscriptions/243 to update an existing subscription. This means that my cached subscriptions collection is now stale data and I want to delete it from my cache so the next request will go to the server.
I've thought of two options, where I'm not sure either are possible:
Can I use a Regexp in the caches.match() call?
This way I could just match the parent collection piece of the requested url with keys found in the cache.
Can I get the keys of each cached data response?
If so, I could just loop through each response and see if the key meets my criteria for deleting it.
Any ideas? Thanks!
Aucun commentaire:
Enregistrer un commentaire