a
This commit is contained in:
parent
3479cc4c07
commit
fb2508f6d8
63
workbox-config.js
Normal file
63
workbox-config.js
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
module.exports = {
|
||||
globDirectory: ".",
|
||||
globPatterns: [
|
||||
"**/*.{css,js,png,jpg,jpeg,svg,gif,webp,woff,woff2,ttf,eot,ico,webmanifest}"
|
||||
],
|
||||
globIgnores: [
|
||||
"node_modules/**",
|
||||
"vendor/**",
|
||||
"**/*.php",
|
||||
"**/*.sql",
|
||||
"**/*.log"
|
||||
],
|
||||
swDest: "sw.js",
|
||||
// Fallback hors ligne pour navigation
|
||||
navigateFallback: "/offline.html",
|
||||
// Exclure certaines routes de navigation si besoin (ex: admin très dynamique)
|
||||
navigateFallbackDenylist: [
|
||||
/\/api\//,
|
||||
/\/ajax\//,
|
||||
/\/Cron\//,
|
||||
/\/backoffice\//
|
||||
],
|
||||
runtimeCaching: [
|
||||
// HTML navigation : NetworkFirst (toujours tenter le réseau, fallback cache)
|
||||
{
|
||||
urlPattern: ({ request }) => request.mode === "navigate",
|
||||
handler: "NetworkFirst",
|
||||
options: {
|
||||
cacheName: "pages",
|
||||
networkTimeoutSeconds: 5,
|
||||
expiration: { maxEntries: 50, maxAgeSeconds: 7 * 24 * 60 * 60 }
|
||||
}
|
||||
},
|
||||
// JS/CSS : StaleWhileRevalidate
|
||||
{
|
||||
urlPattern: ({ request }) =>
|
||||
request.destination === "script" || request.destination === "style",
|
||||
handler: "StaleWhileRevalidate",
|
||||
options: {
|
||||
cacheName: "assets",
|
||||
expiration: { maxEntries: 200, maxAgeSeconds: 30 * 24 * 60 * 60 }
|
||||
}
|
||||
},
|
||||
// Images : CacheFirst
|
||||
{
|
||||
urlPattern: ({ request }) => request.destination === "image",
|
||||
handler: "CacheFirst",
|
||||
options: {
|
||||
cacheName: "images",
|
||||
expiration: { maxEntries: 200, maxAgeSeconds: 60 * 24 * 60 * 60 }
|
||||
}
|
||||
},
|
||||
// Fonts : CacheFirst
|
||||
{
|
||||
urlPattern: ({ request }) => request.destination === "font",
|
||||
handler: "CacheFirst",
|
||||
options: {
|
||||
cacheName: "fonts",
|
||||
expiration: { maxEntries: 50, maxAgeSeconds: 365 * 24 * 60 * 60 }
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user