Ionic PWA increasing cache storage

Untitled

See above image, When I am running web app (IONIC PWA). It increasing cache storage on every refersh and every page loading. Why?

I have enabled service worker too. Can anyone help please. Cache storage increase by 200 mb approx. on every load.

Also PWA is not building using --prod flag. Dev build builind successfully. Anyone help please. urgent.

1 Like

Same problem here.

The cache storage is increasing too much and it is causing a Quota Exceeded Error.

1 Like

Maybe change the maxAgeSeconds of the cache in the service worker will solve the problem:

/**
 * Check out https://googlechrome.github.io/sw-toolbox/docs/master/index.html for
 * more info on how to use sw-toolbox to custom configure your service worker.
 */


'use strict';
importScripts('./build/sw-toolbox.js');

self.toolbox.options.cache = {
  name: 'ionic-cache',
   maxAgeSeconds: 60*8,
  //maxEntries: 2
};

// pre-cache our key assets
self.toolbox.precache(
  [
    './build/main.js',
    './build/main.css',
    './build/polyfills.js',
    'index.html',
    'manifest.json'
  ]
);

// dynamically cache any other local assets
self.toolbox.router.any('/*', self.toolbox.networkFirst);

// for any other requests go to the network, cache,
// and then only use that cached resource if your user goes offline
self.toolbox.router.default = self.toolbox.networkFirst;
1 Like

Is this working for you?

Still testing.

But it seems to have decreased the amount of storage used.

1 Like

Not working at mine side.

Did anyone find a solution about this? I’m having just the same problem with service worker. My app is using a lot of memory in browser and seems is increasing every time I refresh the page. I added the option that @Natanael4354 said, but I think it’s not working right.
This is my service worker right now:

'use strict';
importScripts('./build/sw-toolbox.js');

self.toolbox.options.cache = {
  name: 'ionic-cache',
  maxAgeSeconds: 60
};

// pre-cache our key assets
self.toolbox.precache(
  [
    './build/main.js',
    // './build/vendor.js',
    './build/main.css',
    './build/polyfills.js',
    'index.html',
    'manifest.json'
  ]
);

// dynamically cache any other local assets
self.toolbox.router.any('/*', self.toolbox.fastest);

// for any other requests go to the network, cache,
// and then only use that cached resource if your user goes offline
self.toolbox.router.default = self.toolbox.networkFirst;