Skip to content

Build your personal knowledge base with Trilium Notes

prevent browser from caching images/files, fixes #2378

zadam564366861eb6
diff --git a/src/public/app/widgets/type_widgets/image.js b/src/public/app/widgets/type_widgets/image.js
index 45a9b55e27..ded34470ff 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 6e76d877af..7b0dc751d8 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 ce181ad73c..379eaf65f1 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());
}