diff options
author | Julius Härtl <jus@bitgrid.net> | 2019-01-02 22:27:46 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2019-01-02 22:27:46 +0100 |
commit | 3828283c01a2556783716c9978fbf56f09570529 (patch) | |
tree | 8783180ec844c14e16620ed8923462e89c6bf8c9 /apps | |
parent | 273849a7e775efd5b6cf8dd44eeb589bcda79ec6 (diff) | |
download | nextcloud-server-3828283c01a2556783716c9978fbf56f09570529.tar.gz nextcloud-server-3828283c01a2556783716c9978fbf56f09570529.zip |
Add caching headers for public previews
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/lib/Controller/PublicPreviewController.php | 8 | ||||
-rw-r--r-- | apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/apps/files_sharing/lib/Controller/PublicPreviewController.php b/apps/files_sharing/lib/Controller/PublicPreviewController.php index b13c0a64b0e..33990727ffd 100644 --- a/apps/files_sharing/lib/Controller/PublicPreviewController.php +++ b/apps/files_sharing/lib/Controller/PublicPreviewController.php @@ -119,7 +119,9 @@ class PublicPreviewController extends PublicShareController { } $f = $this->previewManager->getPreview($file, $x, $y, !$a); - return new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); + $response = new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); + $response->cacheFor(3600 * 24); + return $response; } catch (NotFoundException $e) { return new DataResponse([], Http::STATUS_NOT_FOUND); } catch (\InvalidArgumentException $e) { @@ -166,7 +168,9 @@ class PublicPreviewController extends PublicShareController { } $f = $this->previewManager->getPreview($node, -1, -1, false); - return new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); + $response = new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]); + $response->cacheFor(3600 * 24); + return $response; } catch (NotFoundException $e) { return new DataResponse([], Http::STATUS_NOT_FOUND); } catch (\InvalidArgumentException $e) { diff --git a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php index 27e13bc8ced..3cb38a5e388 100644 --- a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php +++ b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php @@ -136,6 +136,7 @@ class PublicPreviewControllerTest extends TestCase { $res = $this->controller->getPreview('token', 'file', 10, 10, true); $expected = new FileDisplayResponse($preview, Http::STATUS_OK, ['Content-Type' => 'myMime']); + $expected->cacheFor(3600 * 24); $this->assertEquals($expected, $res); } @@ -190,6 +191,7 @@ class PublicPreviewControllerTest extends TestCase { $res = $this->controller->getPreview('token', 'file', 10, 10, true); $expected = new FileDisplayResponse($preview, Http::STATUS_OK, ['Content-Type' => 'myMime']); + $expected->cacheFor(3600 * 24); $this->assertEquals($expected, $res); } } |