Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/pmb/node_modules/workbox-recipes/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /*
Copyright 2020 Google LLC
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
import { registerRoute } from 'workbox-routing/registerRoute.js';
import { StaleWhileRevalidate } from 'workbox-strategies/StaleWhileRevalidate.js';
import { CacheFirst } from 'workbox-strategies/CacheFirst.js';
import { CacheableResponsePlugin } from 'workbox-cacheable-response/CacheableResponsePlugin.js';
import { ExpirationPlugin } from 'workbox-expiration/ExpirationPlugin.js';
import './_version.js';
/**
* An implementation of the [Google fonts]{@link https://developers.google.com/web/tools/workbox/guides/common-recipes#google_fonts} caching recipe
*
* @memberof workbox-recipes
*
* @param {Object} [options]
* @param {string} [options.cachePrefix] Cache prefix for caching stylesheets and webfonts. Defaults to google-fonts
* @param {number} [options.maxAgeSeconds] Maximum age, in seconds, that font entries will be cached for. Defaults to 1 year
* @param {number} [options.maxEntries] Maximum number of fonts that will be cached. Defaults to 30
*/
function googleFontsCache(options = {}) {
const sheetCacheName = `${options.cachePrefix || 'google-fonts'}-stylesheets`;
const fontCacheName = `${options.cachePrefix || 'google-fonts'}-webfonts`;
const maxAgeSeconds = options.maxAgeSeconds || 60 * 60 * 24 * 365;
const maxEntries = options.maxEntries || 30;
// Cache the Google Fonts stylesheets with a stale-while-revalidate strategy.
registerRoute(({ url }) => url.origin === 'https://fonts.googleapis.com', new StaleWhileRevalidate({
cacheName: sheetCacheName,
}));
// Cache the underlying font files with a cache-first strategy for 1 year.
registerRoute(({ url }) => url.origin === 'https://fonts.gstatic.com', new CacheFirst({
cacheName: fontCacheName,
plugins: [
new CacheableResponsePlugin({
statuses: [0, 200],
}),
new ExpirationPlugin({
maxAgeSeconds,
maxEntries,
}),
],
}));
}
export { googleFontsCache };
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0552 ]-- |