We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7348139 commit a4f0c40Copy full SHA for a4f0c40
apps/server/src/main.ts
@@ -96,6 +96,18 @@ if (env.PUBLIC_DIR) {
96
await server.register(import("@fastify/static"), {
97
root: publicDir,
98
prefix: "/",
99
+ setHeaders(res, path) {
100
+ if (path.startsWith(`${publicDir}/assets/`)) {
101
+ // Cache assets for 1 year
102
+ res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
103
+ } else if (path.endsWith(".html")) {
104
+ // Do not cache HTML files
105
+ res.setHeader("Cache-Control", "no-cache");
106
+ } else {
107
+ // Cache other files for 1 hour
108
+ res.setHeader("Cache-Control", "public, max-age=3600");
109
+ }
110
+ },
111
});
112
113
server.setNotFoundHandler((_request, reply) => {
0 commit comments