Allow service worker to serve cached unfurl responses

This commit is contained in:
Tom Moor
2023-07-22 13:32:01 -04:00
parent 8d549abaa9
commit cd59af4a9b

View File

@@ -14,8 +14,8 @@ dotenv.config({
silent: true, silent: true,
}); });
export default () => { export default () =>
return defineConfig({ defineConfig({
root: "./", root: "./",
publicDir: "./server/static", publicDir: "./server/static",
base: (process.env.CDN_URL ?? "") + "/static/", base: (process.env.CDN_URL ?? "") + "/static/",
@@ -51,6 +51,22 @@ export default () => {
modifyURLPrefix: { modifyURLPrefix: {
"": `${process.env.CDN_URL ?? ""}/static/`, "": `${process.env.CDN_URL ?? ""}/static/`,
}, },
runtimeCaching: [
{
urlPattern: /api\/urls\.unfurl$/,
handler: "CacheOnly",
options: {
cacheName: "unfurl-cache",
expiration: {
maxEntries: 100,
maxAgeSeconds: 60 * 60,
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
}, },
manifest: { manifest: {
name: "Outline", name: "Outline",
@@ -124,4 +140,3 @@ export default () => {
}, },
}, },
}); });
};