]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add caching to the imageexport plugin
authorRoeland Jago Douma <roeland@famdouma.nl>
Tue, 2 May 2017 10:30:34 +0000 (12:30 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Tue, 2 May 2017 10:30:34 +0000 (12:30 +0200)
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 <roeland@famdouma.nl>
apps/dav/lib/CardDAV/ImageExportPlugin.php

index e48410d26d6e2f6be9d2d1c3a5d23f3a3455a514..3ad7983451b9c9433e855392bf6444f989a43920 100644 (file)
@@ -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);