Skip to content
Advertisement

Service Workers – selectively choose resources

I have a simple Service Worker implementation like this:

JavaScript

My goal is to cache all resources except the two files indicated in the urlsToCache variable, these two files should ALWAYS be requested from the network.. How can i achieve this? How can I then verify that it is actually so?

Advertisement

Answer

You can check the url of the request in fetch event handler before deciding what caching strategy to use:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement