Created Test Environment test.freeplanet.app

and Server: /var/www/test.freeplanet_server
This commit is contained in:
Paolo Arena
2021-09-28 23:44:55 +02:00
parent c16d444d1b
commit 489c4fecc7
39 changed files with 230 additions and 108 deletions

View File

@@ -16,7 +16,7 @@ import { CacheableResponsePlugin } from 'workbox-cacheable-response'
import { ExpirationPlugin } from 'workbox-expiration'
console.log(
' [ VER-0.0.65 ] _---------________------ PAO: this is my custom service worker')
' [ VER-0.1.2b ] _---------________------ PAO: this is my custom service worker')
importScripts('js/idb.js')
importScripts('js/storage.js')
@@ -92,7 +92,7 @@ if (workbox) {
// cleanupOutdatedCaches()
registerRoute(
new RegExp(/\.(?:png|gif|jpg|jpeg|svg)$/),
new RegExp(/\.(?:png|gif|jpg|jpeg)$/),
new CacheFirst({
cacheName: 'images',
plugins: [
@@ -107,6 +107,22 @@ if (workbox) {
],
}),
)
registerRoute(
new RegExp(/\.(?:svg)$/),
new CacheFirst({
cacheName: 'svg',
plugins: [
// Ensure that only requests that result in a 200 status are cached
new CacheableResponsePlugin({
statuses: [200],
}),
new ExpirationPlugin({
maxEntries: 60,
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 Days
}),
],
}),
)
// Per Articoli....
const articleHandler = new NetworkFirst({
@@ -250,9 +266,9 @@ if (workbox) {
)
registerRoute(
new RegExp(/.*\/(?:statics\/icons).*$/),
new RegExp(/.*\/(?:icons).*$/),
new CacheFirst({
cacheName: 'image-cache',
cacheName: 'icon-cache',
plugins: [
// Ensure that only requests that result in a 200 status are cached
new CacheableResponsePlugin({
@@ -558,8 +574,8 @@ self.addEventListener('push', (event) => {
const options = {
body: data.content,
icon: '/public/icons/android-chrome-192x192.png',
badge: '/public/icons/android-chrome-192x192.png',
icon: '/images/android-chrome-192x192.png',
badge: '/images/android-chrome-192x192.png',
data: {
url: data.url,
},