From 59e27f03b641e6048416b4ff252a66adc88100f7 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Tue, 2 May 2017 12:30:34 +0200 Subject: [PATCH] Add caching to the imageexport plugin Since we now heavily use this endpoint for the contacts menu we better set proper caching on the images. Else this gets reload over and over again leading to slow loading menu and unneded bytes transfered. * cache for 1 hour by default * added ETag for validation Signed-off-by: Roeland Jago Douma --- apps/dav/lib/CardDAV/ImageExportPlugin.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/dav/lib/CardDAV/ImageExportPlugin.php b/apps/dav/lib/CardDAV/ImageExportPlugin.php index e48410d26d..3ad7983451 100644 --- a/apps/dav/lib/CardDAV/ImageExportPlugin.php +++ b/apps/dav/lib/CardDAV/ImageExportPlugin.php @@ -86,6 +86,11 @@ class ImageExportPlugin extends ServerPlugin { } if ($result = $this->getPhoto($node)) { + // Allow caching + $response->setHeader('Cache-Control', 'private, max-age=3600, must-revalidate'); + $response->setHeader('Etag', $node->getETag() ); + $response->setHeader('Pragma', 'public'); + $response->setHeader('Content-Type', $result['Content-Type']); $response->setHeader('Content-Disposition', 'attachment'); $response->setStatus(200);