From 99d4cafd83ff6197dfe1931087321cbea68b53f5 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 6 Nov 2017 13:41:49 +0100 Subject: [PATCH] Almost disabled browser caching for unsaved attachments Avoids issues with removed attachments that may still exist in the browser cache and cause the user to believe that it is still there. Commonly an issue with restored messages whose attachments have been automatically removed in the meantime. --- wcfsetup/install/files/lib/page/AttachmentPage.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/page/AttachmentPage.class.php b/wcfsetup/install/files/lib/page/AttachmentPage.class.php index c6e7de0da8..acecb0733b 100644 --- a/wcfsetup/install/files/lib/page/AttachmentPage.class.php +++ b/wcfsetup/install/files/lib/page/AttachmentPage.class.php @@ -132,6 +132,9 @@ class AttachmentPage extends AbstractPage { $location = $this->attachment->getLocation(); } + // unsaved attachments may be cached by the browser for up to 5 minutes only + $cacheDuration = ($this->attachment->tmpHash) ? 300 : 31536000; + // init file reader $this->fileReader = new FileReader($location, array( 'filename' => $this->attachment->filename, @@ -140,8 +143,8 @@ class AttachmentPage extends AbstractPage { 'showInline' => (in_array($mimeType, self::$inlineMimeTypes)), 'enableRangeSupport' => (!$this->tiny && !$this->thumbnail), 'lastModificationTime' => $this->attachment->uploadTime, - 'expirationDate' => TIME_NOW + 31536000, - 'maxAge' => 31536000 + 'expirationDate' => TIME_NOW + $cacheDuration, + 'maxAge' => $cacheDuration )); // add etag for non-thumbnail -- 2.20.1