mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-08 02:43:06 -05:00
chore: changes storage cache to 5 minutes (#5196)
This commit is contained in:
@@ -19,7 +19,7 @@ export const getFile = async (
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": metaData.contentType,
|
"Content-Type": metaData.contentType,
|
||||||
"Content-Disposition": "attachment",
|
"Content-Disposition": "attachment",
|
||||||
"Cache-Control": "public, max-age=1200, s-maxage=1200, stale-while-revalidate=300",
|
"Cache-Control": "public, max-age=300, s-maxage=300, stale-while-revalidate=300",
|
||||||
Vary: "Accept-Encoding",
|
Vary: "Accept-Encoding",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -35,10 +35,7 @@ export const getFile = async (
|
|||||||
status: 302,
|
status: 302,
|
||||||
headers: {
|
headers: {
|
||||||
Location: signedUrl,
|
Location: signedUrl,
|
||||||
"Cache-Control":
|
"Cache-Control": "public, max-age=300, s-maxage=300, stale-while-revalidate=300",
|
||||||
accessType === "public"
|
|
||||||
? `public, max-age=3600, s-maxage=3600, stale-while-revalidate=300`
|
|
||||||
: `public, max-age=600, s-maxage=3600, stale-while-revalidate=300`,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
|
|||||||
@@ -104,9 +104,6 @@ type TGetSignedUrlResponse =
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getS3SignedUrl = async (fileKey: string): Promise<string> => {
|
const getS3SignedUrl = async (fileKey: string): Promise<string> => {
|
||||||
const [_, accessType] = fileKey.split("/");
|
|
||||||
const expiresIn = accessType === "public" ? 60 * 60 : 10 * 60;
|
|
||||||
|
|
||||||
const getObjectCommand = new GetObjectCommand({
|
const getObjectCommand = new GetObjectCommand({
|
||||||
Bucket: S3_BUCKET_NAME,
|
Bucket: S3_BUCKET_NAME,
|
||||||
Key: fileKey,
|
Key: fileKey,
|
||||||
@@ -114,7 +111,7 @@ const getS3SignedUrl = async (fileKey: string): Promise<string> => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const s3Client = getS3Client();
|
const s3Client = getS3Client();
|
||||||
return await getSignedUrl(s3Client, getObjectCommand, { expiresIn });
|
return await getSignedUrl(s3Client, getObjectCommand, { expiresIn: 30 * 60 });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user