From 564366861eb6110beea8921f67e9df3f39025e3f Mon Sep 17 00:00:00 2001 From: zadam Date: Thu, 25 Nov 2021 20:24:42 +0100 Subject: [PATCH] prevent browser from caching images/files, fixes #2378 --- src/public/app/widgets/type_widgets/image.js | 4 +--- src/routes/api/files.js | 1 + src/routes/api/image.js | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/public/app/widgets/type_widgets/image.js b/src/public/app/widgets/type_widgets/image.js index 45a9b55e2..ded34470f 100644 --- a/src/public/app/widgets/type_widgets/image.js +++ b/src/public/app/widgets/type_widgets/image.js @@ -57,9 +57,7 @@ class ImageTypeWidget extends TypeWidget { } async doRefresh(note) { - const imageHash = utils.randomString(10); - - this.$imageView.prop("src", `api/images/${note.noteId}/${note.title}?${imageHash}`); + this.$imageView.prop("src", `api/images/${note.noteId}/${note.title}`); } copyImageToClipboardEvent({ntxId}) { diff --git a/src/routes/api/files.js b/src/routes/api/files.js index 6e76d877a..7b0dc751d 100644 --- a/src/routes/api/files.js +++ b/src/routes/api/files.js @@ -60,6 +60,7 @@ function downloadNoteFile(noteId, res, contentDisposition = true) { res.setHeader('Content-Disposition', utils.getContentDisposition(filename)); } + res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); res.setHeader('Content-Type', note.mime); res.send(note.getContent()); diff --git a/src/routes/api/image.js b/src/routes/api/image.js index ce181ad73..379eaf65f 100644 --- a/src/routes/api/image.js +++ b/src/routes/api/image.js @@ -20,6 +20,7 @@ function returnImage(req, res) { } res.set('Content-Type', image.mime); + res.set("Cache-Control", "no-cache, no-store, must-revalidate"); res.send(image.getContent()); }