There are many thoughts about should you build a progressive web app or a native. Recently, we shared with you an opinion on why your web project should be a PWA. As always, you need to make a decision by yourself but for you to be prepared, we want to present to you some caching strategies for PWA.
PWA (Progressive Web App) is an app within your browser, displayed as a website. The ‘PWA’ is mostly the marketing term but no longer just a Google thing. You can take it as a website with a special power. Choosing the right strategy is important. These are the most common:
- Cache only
It returns a resource from the cache without network. This strategy works for serving assets pre-cached for the installation of a service.
- Network only
It needs a network to get a resource. Good if stale or cached version is unacceptable.
- Cache First
It gets a resource from the cache first. When it’s found, we return it and no request is made. It’s good for caching assets and repetitive requests.
- Network First
This one tries to get the resource over the network first. It works for resources that always need to be fresh.
- Stale while revalidate
It serves a resource from the cache and in the result, we’ve got a corresponding request.
These are the main strategies and if you want to find out more, please read this material.
And by the way, from now, publishing your PWA in the Store – as well as from the browser – is possible as Google Play Store now open for PWA.