PWA Service worker - Network falling back to cache

I have started to test building a PWA for a site that contains news articles.

The service worker method that would suite this best would be Network falling back to cache.

The service worker should cache logotype, css, google fonts etc.
It should also cache the index file and article images BUT when there is network access these files should be cleared. Since index file changes a lot and new article images are added we don’t want to keep an cache of old article images. Ultimately if we display 10 articles and keep these in cache and add a new article only the oldest article which is not displayed anymore would be cut of the cache.

But if we keep it simple and just use one cache and clear all cache if network is available how could this be accomplished?

In the article above there is a link under “Network falling back to cache” called update the cache entry but I can’t see any code that would do this.

All the resources I have found while googling seems to be more oriented to PWA’s that don’t update that often. Any suggestions would be really appreciated.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.