Add cache to files page
This commit is contained in:
parent
1369af0484
commit
4d728ed349
@ -14,7 +14,6 @@ export default function File({ isValidFile, fileData }) {
|
|||||||
fileId,
|
fileId,
|
||||||
originalFileName,
|
originalFileName,
|
||||||
uploadDate,
|
uploadDate,
|
||||||
contentType,
|
|
||||||
fileUrl,
|
fileUrl,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
@ -141,9 +140,13 @@ export default function File({ isValidFile, fileData }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getServerSideProps(ctx) {
|
export async function getServerSideProps({ query, res }) {
|
||||||
let { fileId } = ctx.query;
|
let { fileId } = query;
|
||||||
fileId = fileId.split(".")[0];
|
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);
|
const file = await getFileInfo(fileId);
|
||||||
return {
|
return {
|
||||||
|
Reference in New Issue
Block a user