Created
June 2, 2020 06:45
-
-
Save dreamer01/0b4ef654d9ef98935b66b68b83776e34 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
module.exports = [ | |
{ | |
urlPattern: /^https:\/\/fonts\.(?:googleapis|gstatic)\.com\/.*/i, | |
handler: "CacheFirst", | |
options: { | |
cacheName: "google-fonts", | |
expiration: { | |
maxEntries: 4, | |
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days | |
}, | |
}, | |
}, | |
{ | |
urlPattern: /^https:\/\/use\.fontawesome\.com\/releases\/.*/i, | |
handler: "CacheFirst", | |
options: { | |
cacheName: "font-awesome", | |
expiration: { | |
maxEntries: 1, | |
maxAgeSeconds: 365 * 24 * 60 * 60, // 365 days | |
}, | |
}, | |
}, | |
{ | |
urlPattern: /\.(?:eot|otf|ttc|ttf|woff|woff2|font.css)$/i, | |
handler: "StaleWhileRevalidate", | |
options: { | |
cacheName: "static-font-assets", | |
expiration: { | |
maxEntries: 4, | |
maxAgeSeconds: 7 * 24 * 60 * 60, // 7 days | |
}, | |
}, | |
}, | |
{ | |
urlPattern: /\.(?:jpg|jpeg|gif|png|svg|ico|webp)$/i, | |
handler: "StaleWhileRevalidate", | |
options: { | |
cacheName: "static-image-assets", | |
expiration: { | |
maxEntries: 64, | |
maxAgeSeconds: 24 * 60 * 60, // 24 hours | |
}, | |
}, | |
}, | |
{ | |
urlPattern: /\.(?:js)$/i, | |
handler: "StaleWhileRevalidate", | |
options: { | |
cacheName: "static-js-assets", | |
expiration: { | |
maxEntries: 16, | |
maxAgeSeconds: 24 * 60 * 60, // 24 hours | |
}, | |
}, | |
}, | |
{ | |
urlPattern: /\.(?:css|less)$/i, | |
handler: "StaleWhileRevalidate", | |
options: { | |
cacheName: "static-style-assets", | |
expiration: { | |
maxEntries: 16, | |
maxAgeSeconds: 24 * 60 * 60, // 24 hours | |
}, | |
}, | |
}, | |
{ | |
urlPattern: /\.(?:json|xml|csv)$/i, | |
handler: "StaleWhileRevalidate", | |
options: { | |
cacheName: "static-data-assets", | |
expiration: { | |
maxEntries: 16, | |
maxAgeSeconds: 24 * 60 * 60, // 24 hours | |
}, | |
}, | |
}, | |
{ | |
urlPattern: /\/api\/.*/g, | |
handler: "NetworkOnly", | |
}, | |
{ | |
urlPattern: /.*/i, | |
handler: "StaleWhileRevalidate", | |
options: { | |
cacheName: "others", | |
expiration: { | |
maxEntries: 16, | |
maxAgeSeconds: 24 * 60 * 60, // 24 hours | |
}, | |
}, | |
}, | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment