A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
perf(server): cache fixed-name images and fonts for 30 days
Amruth Pillai1003b1d8a5d1
diff --git a/apps/server/src/static/web.ts b/apps/server/src/static/web.tsindex c6d97e323..91989d4eb 100644--- a/apps/server/src/static/web.ts+++ b/apps/server/src/static/web.ts@@ -280,6 +280,8 @@ function readPageMeta(html: string, fallback: { title: string; description: stri};}+const mediaFile = /\.(?:avif|gif|ico|jpe?g|mp3|png|svg|ttf|webp|woff2?)$/i;+export const serveWebDistStatic = env.CLOUDFLARE? undefined: serveStatic({@@ -287,11 +289,16 @@ export const serveWebDistStatic = env.CLOUDFLARE// The Docker build writes brotli copies beside the text files and WASM (tooling/docker/precompress.mjs).precompressed: true,onFound: (_path, context) => {- // Vite fingerprints everything under /assets, so a file there never changes. Other files keep their names- // when their content changes, so a release purges them from Cloudflare's cache by this tag.- if (context.req.path.startsWith("/assets/"))+ // Vite fingerprints everything under /assets, so a file there never changes.+ if (context.req.path.startsWith("/assets/")) {context.header("Cache-Control", "public, max-age=31536000, immutable");- else context.header("Cache-Tag", "public");+ } else {+ // Other files keep their names when their content changes, so a release purges them from Cloudflare's+ // cache by this tag. Browsers keep pictures, fonts and sounds for 30 days, the shortest lifetime Lighthouse+ // doesn't count as waste; one replaced under the same name reaches every visitor within that month.+ context.header("Cache-Tag", "public");+ if (mediaFile.test(context.req.path)) context.header("Cache-Control", "public, max-age=2592000");+ }// `/index.html` is the app shell too; it must not be frameable either.if (context.req.path.endsWith(".html"))for (const [name, value] of Object.entries(BASE_SECURITY_HEADERS)) context.header(name, value);