Set max-age and expire header for caching

This commit is contained in:
Stefan Forstenlechner 2022-04-17 14:12:13 +02:00
parent 48bec4752a
commit 71711bb698
1 changed files with 12 additions and 1 deletions

View File

@ -14,7 +14,18 @@ const app = express();
const PORT = process.env.PORT || 3001;
app.use("/images", express.static(publicPath));
app.use(
"/images",
express.static(publicPath, {
maxAge: 2592000000,
setHeaders(res, _) {
res.setHeader(
"Expires",
new Date(Date.now() + 2592000000 * 30).toUTCString()
);
},
})
);
app.use(express.static("../picture-gallery-client/build"));