source: frontend/node_modules/workbox-cacheable-response/CacheableResponsePlugin.js

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

Fix frontend appearance

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 Copyright 2018 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 { CacheableResponse, } from './CacheableResponse.js';
9import './_version.js';
10/**
11 * A class implementing the `cacheWillUpdate` lifecycle callback. This makes it
12 * easier to add in cacheability checks to requests made via Workbox's built-in
13 * strategies.
14 *
15 * @memberof workbox-cacheable-response
16 */
17class CacheableResponsePlugin {
18 /**
19 * To construct a new CacheableResponsePlugin instance you must provide at
20 * least one of the `config` properties.
21 *
22 * If both `statuses` and `headers` are specified, then both conditions must
23 * be met for the `Response` to be considered cacheable.
24 *
25 * @param {Object} config
26 * @param {Array<number>} [config.statuses] One or more status codes that a
27 * `Response` can have and be considered cacheable.
28 * @param {Object<string,string>} [config.headers] A mapping of header names
29 * and expected values that a `Response` can have and be considered cacheable.
30 * If multiple headers are provided, only one needs to be present.
31 */
32 constructor(config) {
33 /**
34 * @param {Object} options
35 * @param {Response} options.response
36 * @return {Response|null}
37 * @private
38 */
39 this.cacheWillUpdate = async ({ response }) => {
40 if (this._cacheableResponse.isResponseCacheable(response)) {
41 return response;
42 }
43 return null;
44 };
45 this._cacheableResponse = new CacheableResponse(config);
46 }
47}
48export { CacheableResponsePlugin };
Note: See TracBrowser for help on using the repository browser.