@@ -81,7 +81,7 @@ if (workbox) {
|
||||
|
||||
workbox.routing.registerRoute(
|
||||
new RegExp(/\.(?:png|gif|jpg|jpeg|svg)$/),
|
||||
workbox.strategies.staleWhileRevalidate({
|
||||
workbox.strategies.CacheFirst({
|
||||
cacheName: 'images',
|
||||
plugins: [
|
||||
new workbox.expiration.Plugin({
|
||||
@@ -92,6 +92,22 @@ if (workbox) {
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
// Per Articoli....
|
||||
const articleHandler = workbox.strategies.networkFirst({
|
||||
cacheName: 'articles-cache',
|
||||
plugins: [
|
||||
new workbox.expiration.Plugin({
|
||||
maxEntries: 50,
|
||||
})
|
||||
]
|
||||
});
|
||||
|
||||
workbox.routing.registerRoute(/(.*)article(.*)\.html/, args => {
|
||||
return articleHandler.handle(args);
|
||||
});
|
||||
|
||||
|
||||
workbox.routing.registerRoute(
|
||||
new RegExp(/.*(?:googleapis|gstatic)\.com.*$/),
|
||||
workbox.strategies.staleWhileRevalidate({
|
||||
@@ -218,18 +234,13 @@ if (workbox) {
|
||||
);
|
||||
|
||||
workbox.routing.registerRoute(
|
||||
new RegExp(/.*\/(?:css|font).*/),
|
||||
workbox.strategies.cacheFirst({
|
||||
cacheName: 'css-fonts',
|
||||
plugins: [
|
||||
new workbox.expiration.Plugin({
|
||||
maxAgeSeconds: 30 * 24 * 60 * 60,
|
||||
}),
|
||||
]
|
||||
})
|
||||
new RegExp(/\.(?:js|css|font)$/),
|
||||
new workbox.strategies.StaleWhileRevalidate( {
|
||||
cacheName: 'js-css-fonts',
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
workbox.routing.registerRoute(
|
||||
new RegExp('https://cdnjs.coudflare.com/ajax/libs/material-design-lite/1.3.0/material.indigo-pink.min.css'),
|
||||
workbox.strategies.staleWhileRevalidate({
|
||||
@@ -241,6 +252,7 @@ if (workbox) {
|
||||
]
|
||||
})
|
||||
);
|
||||
*/
|
||||
|
||||
// Storage
|
||||
workbox.routing.registerRoute(
|
||||
@@ -270,6 +282,7 @@ if (workbox) {
|
||||
})
|
||||
);
|
||||
|
||||
/*
|
||||
workbox.routing.registerRoute(
|
||||
new RegExp(/^http/),
|
||||
workbox.strategies.networkFirst({
|
||||
@@ -282,6 +295,7 @@ if (workbox) {
|
||||
]
|
||||
})
|
||||
);
|
||||
*/
|
||||
|
||||
|
||||
workbox.routing.registerRoute(
|
||||
|
||||
Reference in New Issue
Block a user