source: frontend/node_modules/workbox-precaching/cleanupOutdatedCaches.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 Copyright 2019 Google LLC
3
4 Use of this source code is governed by an MIT-style
5 license that can be found in the LICENSE file or at
6 https://opensource.org/licenses/MIT.
7*/
8import { cacheNames } from 'workbox-core/_private/cacheNames.js';
9import { logger } from 'workbox-core/_private/logger.js';
10import { deleteOutdatedCaches } from './utils/deleteOutdatedCaches.js';
11import './_version.js';
12/**
13 * Adds an `activate` event listener which will clean up incompatible
14 * precaches that were created by older versions of Workbox.
15 *
16 * @memberof workbox-precaching
17 */
18function cleanupOutdatedCaches() {
19 // See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705
20 self.addEventListener('activate', ((event) => {
21 const cacheName = cacheNames.getPrecacheName();
22 event.waitUntil(deleteOutdatedCaches(cacheName).then((cachesDeleted) => {
23 if (process.env.NODE_ENV !== 'production') {
24 if (cachesDeleted.length > 0) {
25 logger.log(`The following out-of-date precaches were cleaned up ` +
26 `automatically:`, cachesDeleted);
27 }
28 }
29 }));
30 }));
31}
32export { cleanupOutdatedCaches };
Note: See TracBrowser for help on using the repository browser.