Answers for "workbox example"

0

workbox example

// workbox webpack config

new GenerateSW({
			swDest: resolve(process.cwd(), 'build/service-worker.js'),
			runtimeCaching: [
				{
					handler: 'StaleWhileRevalidate',
					urlPattern: /\.(?:js|css|html)$/,
					options: {
						cacheName: 'static-assets-cache',
						cacheableResponse: {
							statuses: [0, 200]
						},
						expiration: {
							maxEntries: 100,
							maxAgeSeconds: 24 * 60 * 60 * 60
						}
					}
				},
				{
					handler: 'CacheFirst',
					urlPattern: /\.(?:jp?g|png|svg|gif|raw|webp)$/,
					options: {
						cacheName: 'images-assets-cache',
						cacheableResponse: {
							statuses: [200]
						},
						expiration: {
							maxEntries: 100,
							maxAgeSeconds: 24 * 60 * 60 * 180
						}
					}
				},
				{
					handler: 'CacheFirst',
					urlPattern: /\.(?:woff|woff2|eot|ttf|otf)$/,
					options: {
						cacheName: 'fonts-assets-cache',
						cacheableResponse: {
							statuses: [200]
						},
						expiration: {
							maxEntries: 100,
							maxAgeSeconds: 24 * 60 * 60 * 180
						}
					}
				}
			],
			clientsClaim: true,
			skipWaiting: true,
			cleanupOutdatedCaches: true
		}),
Posted by: Guest on September-03-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language