Dynamically Caching Static-Content

Let's learn how to dynamically add assets to the cache storage.

The dynamic cache contains assets that are not cached during static caching. We don’t manually define the items to store in it. In this cache, we dynamically store the assets users request while using the app. By requesting these assets, the user expresses a need for them to be offline.

This type of caching content is still static, like files, images, scripts, etc. The only difference from static caching is that these assets are stored only when the user fetches them at least once. While in static caching, we specifically defined which assets to store in the cache.

We need dynamic caching because static caching doesn’t cover the files from the entire app. We only store the app shell in the static cache. If we try to fetch any asset other than the app shell while offline, we get an error. Therefore, we can serve the dynamically cached asset during the subsequent offline visits of the user.

Get hands-on with 1200+ tech skills courses.