|
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 2020 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 |
|
|---|
| 9 | import {WorkboxPlugin, WorkboxPluginCallbackParam} from 'workbox-core/types.js';
|
|---|
| 10 |
|
|---|
| 11 | import {PrecacheController} from '../PrecacheController.js';
|
|---|
| 12 |
|
|---|
| 13 | import '../_version.js';
|
|---|
| 14 |
|
|---|
| 15 | /**
|
|---|
| 16 | * A plugin, designed to be used with PrecacheController, to translate URLs into
|
|---|
| 17 | * the corresponding cache key, based on the current revision info.
|
|---|
| 18 | *
|
|---|
| 19 | * @private
|
|---|
| 20 | */
|
|---|
| 21 | class PrecacheCacheKeyPlugin implements WorkboxPlugin {
|
|---|
| 22 | private readonly _precacheController: PrecacheController;
|
|---|
| 23 |
|
|---|
| 24 | constructor({precacheController}: {precacheController: PrecacheController}) {
|
|---|
| 25 | this._precacheController = precacheController;
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | cacheKeyWillBeUsed: WorkboxPlugin['cacheKeyWillBeUsed'] = async ({
|
|---|
| 29 | request,
|
|---|
| 30 | params,
|
|---|
| 31 | }: WorkboxPluginCallbackParam['cacheKeyWillBeUsed']) => {
|
|---|
| 32 | // Params is type any, can't change right now.
|
|---|
| 33 | /* eslint-disable */
|
|---|
| 34 | const cacheKey =
|
|---|
| 35 | params?.cacheKey ||
|
|---|
| 36 | this._precacheController.getCacheKeyForURL(request.url);
|
|---|
| 37 | /* eslint-enable */
|
|---|
| 38 |
|
|---|
| 39 | return cacheKey
|
|---|
| 40 | ? new Request(cacheKey, {headers: request.headers})
|
|---|
| 41 | : request;
|
|---|
| 42 | };
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | export {PrecacheCacheKeyPlugin};
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.