perf: optimize slider image persistence in DOM and add 1-year immutable cache-control for static uploads
Deploy Canina / deploy (push) Successful in 1m41s
Deploy Canina / deploy (push) Successful in 1m41s
This commit is contained in:
1 parent
5bf9ac0b2e
commit
eb63d22ac4
2 files changed
+36
-14
No files matched your search
+11
-1
@@ -28,12 +28,22 @@ async function bootstrap() {
|
||||
// Trust reverse proxy (Nginx / Docker ingress) to resolve real client IP from X-Forwarded-For
|
||||
app.set('trust proxy', true);
|
||||
|
||||
// Serve static uploads folder under both /uploads/ and /api/uploads/
|
||||
// Serve static uploads folder with 1-year aggressive browser caching (immutable)
|
||||
const staticUploadOptions = {
|
||||
maxAge: 31536000000, // 1 year in ms
|
||||
immutable: true,
|
||||
setHeaders: (res: any) => {
|
||||
res.setHeader('Cache-Control', 'public, max-age=31536000, immutable');
|
||||
},
|
||||
};
|
||||
|
||||
app.useStaticAssets(join(process.cwd(), 'uploads'), {
|
||||
prefix: '/uploads/',
|
||||
...staticUploadOptions,
|
||||
});
|
||||
app.useStaticAssets(join(process.cwd(), 'uploads'), {
|
||||
prefix: '/api/uploads/',
|
||||
...staticUploadOptions,
|
||||
});
|
||||
|
||||
app.use(
|
||||
|
||||
Reference in new issue
Block a user