The Cache-on-Demand Strategy
Learn how to store assets in the cache storage when a user wants to.
We'll cover the following
The workings of the strategy
Developers might not be sure about pre-caching some assets. In these situations, it’s best to let the users decide if they want to cache those assets for the future. The caching strategy used in this situation is cache-on-demand, in which the user triggers the caching in the form of events like clicking a “Save” or “Download” button.
Remember that the cache-on-demand strategy doesn’t work with dynamic cache, as the latter stores the assets without the user’s intention. Another thing to remember is that this strategy requires the user gesture to trigger caching, and we can only listen to the user gestures in the page’s main JavaScript thread and not from the service worker.
Get hands-on with 1400+ tech skills courses.