source: frontend/node_modules/workbox-precaching/src/cleanupOutdatedCaches.ts

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
RevLine 
[9af201e]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*/
8
9import {cacheNames} from 'workbox-core/_private/cacheNames.js';
10import {logger} from 'workbox-core/_private/logger.js';
11import {deleteOutdatedCaches} from './utils/deleteOutdatedCaches.js';
12import './_version.js';
13
14/**
15 * Adds an `activate` event listener which will clean up incompatible
16 * precaches that were created by older versions of Workbox.
17 *
18 * @memberof workbox-precaching
19 */
20function cleanupOutdatedCaches(): void {
21 // See https://github.com/Microsoft/TypeScript/issues/28357#issuecomment-436484705
22 self.addEventListener('activate', ((event: ExtendableEvent) => {
23 const cacheName = cacheNames.getPrecacheName();
24
25 event.waitUntil(
26 deleteOutdatedCaches(cacheName).then((cachesDeleted) => {
27 if (process.env.NODE_ENV !== 'production') {
28 if (cachesDeleted.length > 0) {
29 logger.log(
30 `The following out-of-date precaches were cleaned up ` +
31 `automatically:`,
32 cachesDeleted,
33 );
34 }
35 }
36 }),
37 );
38 }) as EventListener);
39}
40
41export {cleanupOutdatedCaches};
Note: See TracBrowser for help on using the repository browser.