Service Workers - Advanced Caching

Cache on Demand

Till now either we were caching all the dynamic requests or we can remove all the dynamic requests,
we can also cache on Demand , note that we can add responses to cache from front-end js codes as well this , so while we are doing some fetch we can decide whether we  want to cache its response or not .
also note that cache.add (some url)  can do both request for resource and cache it


ex


this function is a event Listener ,which is normal js function (not in sw.js) which  is adding some resource to cache so that in future those resources can be served from cache if needed

Also while using cache from front-end js file much check whether cache is available in that browser or not



Comments

Popular posts from this blog

manifest file

service worker caching

Service Worker Basics