Skip to content

Commit

Permalink
cache cdn assets
Browse files Browse the repository at this point in the history
  • Loading branch information
ibastawisi committed Aug 28, 2024
1 parent dbfeec6 commit bc6a9a0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions next-pwa/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
// Workbox RuntimeCaching config: https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-build#.RuntimeCachingEntry
/** @type {import('workbox-build').RuntimeCaching[]} */
module.exports = [
{
urlPattern: ({ url: { pathname }, sameOrigin }) => {
if (!sameOrigin) return false;
return pathname.startsWith("/cdn-cgi");
},
handler: "CacheFirst",
options: {
cacheName: "cdn-assets",
expiration: {
maxEntries: 4,
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days
},
},
},
{
urlPattern: ({ url: { pathname }, sameOrigin }) => {
if (!sameOrigin) return false;
Expand Down

0 comments on commit bc6a9a0

Please sign in to comment.