Search code examples
browser-cacheworkbox

What's the default expiration time for cache storage


I am using workbox to cache resources and assets for a website. I want to know is there a default expiration time for these resources? or do I have to set one?

This is a sample of one of my caching recipes

/**
 * Cache CSS
 */
workbox.routing.registerRoute(/cache\/css\/.+/,  workbox.strategies.cacheFirst({
    cacheName: 'styles',
    plugins: [
      new workbox.expiration.Plugin({
        maxEntries: 20,
      }),
    ],
}));

The workbox guides shows that I can add custom expiration time.

new workbox.expiration.Plugin({
  maxEntries: 50,
  maxAgeSeconds: 5 * 60, // 5 minutes
}),

I want to know if theres anyway I can find the default expiration time, I tried to play around chrome dev tools, but didn't find anything mentioning the expiration time of cache storage.


Solution

  • I don't think that there's any default expiration time if you don't set it up yourself.

    If you don't specify anything, then it will simply follow browser's cache eviction strategy when cache will be full.

    Offline Storage for Progressive Web Apps