Add cache to files page

This commit is contained in:
Lee 2022-11-17 08:00:45 +00:00
parent 1369af0484
commit 4d728ed349
No known key found for this signature in database
GPG Key ID: 6EA25896ECCB3121

@ -14,7 +14,6 @@ export default function File({ isValidFile, fileData }) {
fileId,
originalFileName,
uploadDate,
contentType,
fileUrl,
width,
height,
@ -141,9 +140,13 @@ export default function File({ isValidFile, fileData }) {
);
}
export async function getServerSideProps(ctx) {
let { fileId } = ctx.query;
export async function getServerSideProps({ query, res }) {
let { fileId } = query;
fileId = fileId.split(".")[0];
res.setHeader(
"Cache-Control",
"public, s-maxage=10, stale-while-revalidate=300" // Cache for 5 minutes
);
const file = await getFileInfo(fileId);
return {