Skip to content

Commit

Permalink
Set cache headers for static asset responses
Browse files Browse the repository at this point in the history
Added a `Cache-Control` header to static asset responses to ensure proper caching. This improves performance by allowing public, immutable assets to be cached for 30 days.

Signed-off-by: Akama Aka <akama.aka@akami-solutions.cc>
  • Loading branch information
akama-aka committed Feb 18, 2025
1 parent 91df258 commit 1e1792f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const server = require('fastify')({logger: process})
timeWindow: '15 minutes' // time window for the rate limit
}).register(require('@fastify/static'), { // For all Static files like Styling, JavaScript Cde
prefix: `/${process.env.PATH_IDENTIFIER}/assets/`,
preCompressed: true,
setHeaders: (res) => {
res.setHeader('Cache-Control', 'public, immutable, max-age=2592000');
},
root: join(__dirname + '/public/assets/')
})
Expand Down

0 comments on commit 1e1792f

Please sign in to comment.