diff --git a/server/models/Attachment.ts b/server/models/Attachment.ts index c0d1a19da..26e794cc2 100644 --- a/server/models/Attachment.ts +++ b/server/models/Attachment.ts @@ -108,7 +108,7 @@ class Attachment extends IdModel { } /** - * Get a signed URL with the default expirt to download the attachment from storage. + * Get a signed URL with the default expiry to download the attachment from storage. */ get signedUrl() { return FileStorage.getSignedUrl(this.key); diff --git a/server/routes/api/attachments/attachments.ts b/server/routes/api/attachments/attachments.ts index 8552ad6a4..6dd47375c 100644 --- a/server/routes/api/attachments/attachments.ts +++ b/server/routes/api/attachments/attachments.ts @@ -13,6 +13,7 @@ import AttachmentHelper from "@server/models/helpers/AttachmentHelper"; import { authorize } from "@server/policies"; import { presentAttachment } from "@server/presenters"; import FileStorage from "@server/storage/files"; +import BaseStorage from "@server/storage/files/BaseStorage"; import { APIContext } from "@server/types"; import { RateLimiterStrategy } from "@server/utils/RateLimiter"; import { assertIn } from "@server/validation"; @@ -171,8 +172,13 @@ const handleAttachmentsRedirect = async ( }); if (attachment.isPrivate) { + ctx.set( + "Cache-Control", + `max-age=${BaseStorage.defaultSignedUrlExpires}, immutable` + ); ctx.redirect(await attachment.signedUrl); } else { + ctx.set("Cache-Control", `max-age=604800, immutable`); ctx.redirect(attachment.canonicalUrl); } }; diff --git a/shared/editor/lib/uploadPlaceholder.tsx b/shared/editor/lib/uploadPlaceholder.tsx index 7b80c4cf7..67361deeb 100644 --- a/shared/editor/lib/uploadPlaceholder.tsx +++ b/shared/editor/lib/uploadPlaceholder.tsx @@ -2,7 +2,6 @@ import { EditorState, Plugin } from "prosemirror-state"; import { Decoration, DecorationSet } from "prosemirror-view"; import * as React from "react"; import ReactDOM from "react-dom"; -import Logger from "~/utils/Logger"; import FileExtension from "../components/FileExtension"; import { recreateTransform } from "./prosemirror-recreate-transform"; @@ -24,7 +23,8 @@ const uploadPlaceholder = new Plugin({ simplifyDiff: true, }).mapping; } catch (err) { - Logger.warn("Failed to recreate transform", err); + // eslint-disable-next-line no-console + console.warn("Failed to recreate transform: ", err); } }