Clear service worker cache from Android API -
we have native andorid app webviews. using service worker functionality in android webviews.
http://www.html5rocks.com/en/tutorials/service-worker/introduction/
is there way clear out service worker cache android api? want clear cache when user logs out android app.
i'm not android developer, webstorage#deletealldata()
method looks accomplish you'd want. if doesn't, sounds bug, , i'd recommend follow via whatever mechanism used android framework bugs.
alternatively, , since web developer, here's javascript approach clearing things out. note you're referring "service worker cache" isn't limited service workers; cache storage api exposed in both work global scope , window.caches
, used directly context of web pages. can run code deletes of caches directly web page execution context, without jumping through hoops trigger service worker:
caches.keys() .then(cachenames => promise.all(cachenames.map(cachename => caches.delete(cachename)))) .then(() => console.log('everything deleted!')) .catch(error => console.warn('something went wrong!', error));
unlike webstorage#deletealldata()
call, javascript clear cache storage api, normal http cache, cookies , other site-specific storage still remain.
Comments
Post a Comment