forked from Mirrors/elk
Compare commits
6 commits
main
...
userquin/f
Author | SHA1 | Date | |
---|---|---|---|
|
55e855181d | ||
|
3f3cb16979 | ||
|
0cfd6a1d33 | ||
|
40b472ce9d | ||
|
44d0e9c300 | ||
|
059502f3e2 |
1 changed files with 14 additions and 9 deletions
|
@ -44,20 +44,21 @@ if (import.meta.env.PROD) {
|
||||||
// exclude shiki: has its own cache
|
// exclude shiki: has its own cache
|
||||||
/^\/emojis\//,
|
/^\/emojis\//,
|
||||||
// exclude sw: if the user navigates to it, fallback to index.html
|
// exclude sw: if the user navigates to it, fallback to index.html
|
||||||
/^\/sw.js$/,
|
/^\/sw\.js$/,
|
||||||
// exclude webmanifest: has its own cache
|
// exclude web manifest: has its own cache, if the user navigates to it, fallback to index.html
|
||||||
/^\/manifest-(.*).webmanifest$/,
|
/^\/manifest-(.*)\.webmanifest$/,
|
||||||
]
|
]
|
||||||
}
|
|
||||||
|
|
||||||
// only cache pages and external assets on local build + start or in production
|
// only cache pages and external assets on local build + start or in production
|
||||||
if (import.meta.env.PROD) {
|
// include webmanifest and images cache
|
||||||
// include webmanifest cache
|
|
||||||
registerRoute(
|
registerRoute(
|
||||||
({ request, sameOrigin }) =>
|
({ request, sameOrigin }) => sameOrigin && request.destination === 'manifest',
|
||||||
sameOrigin && request.destination === 'manifest',
|
|
||||||
new NetworkFirst({
|
new NetworkFirst({
|
||||||
cacheName: 'elk-webmanifest',
|
cacheName: 'elk-webmanifest',
|
||||||
|
// responses with a Vary: Accept-Encoding header
|
||||||
|
matchOptions: {
|
||||||
|
ignoreVary: true,
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new CacheableResponsePlugin({ statuses: [200] }),
|
new CacheableResponsePlugin({ statuses: [200] }),
|
||||||
// we only need a few entries
|
// we only need a few entries
|
||||||
|
@ -86,6 +87,10 @@ if (import.meta.env.PROD) {
|
||||||
&& url.pathname.startsWith('/emojis/'),
|
&& url.pathname.startsWith('/emojis/'),
|
||||||
new StaleWhileRevalidate({
|
new StaleWhileRevalidate({
|
||||||
cacheName: 'elk-emojis',
|
cacheName: 'elk-emojis',
|
||||||
|
// responses with a Vary: Accept-Encoding header
|
||||||
|
matchOptions: {
|
||||||
|
ignoreVary: true,
|
||||||
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
new CacheableResponsePlugin({ statuses: [200] }),
|
new CacheableResponsePlugin({ statuses: [200] }),
|
||||||
// 15 days max
|
// 15 days max
|
||||||
|
|
Loading…
Reference in a new issue