diff --git a/client/bin/client.js b/client/bin/client.js index d30cc70..7179e19 100755 --- a/client/bin/client.js +++ b/client/bin/client.js @@ -9,10 +9,34 @@ const __dirname = dirname(fileURLToPath(import.meta.url)); const distPath = join(__dirname, "../dist"); const server = http.createServer((request, response) => { - return handler(request, response, { + const handlerOptions = { public: distPath, rewrites: [{ source: "/**", destination: "/index.html" }], - }); + headers: [ + { + // Ensure index.html is never cached + source: "index.html", + headers: [ + { + key: "Cache-Control", + value: "no-cache, no-store, max-age=0", + }, + ], + }, + { + // Allow long-term caching for hashed assets + source: "assets/**", + headers: [ + { + key: "Cache-Control", + value: "public, max-age=31536000, immutable", + }, + ], + }, + ], + }; + + return handler(request, response, handlerOptions); }); const port = process.env.PORT || 6274;