How can I add Cache-Control headers to static files and route responses in Solid Start?
1 Answer
Since Solid Start uses Nitro you can just add this to your app.config.ts file:
import { defineConfig } from "@solidjs/start/config";
const aYear = 31536000;
export default defineConfig({
server: {
// ...
routeRules: {
"/images/**": {
headers: {
"cache-control": `public,max-age=${aYear},s-maxage=${aYear}`,
},
},
},
},
});