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 <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2017-05-02 12:30:34 +02:00
parent 94c2f12226
commit 59e27f03b6
No known key found for this signature in database
GPG Key ID: F941078878347C0C
1 changed files with 5 additions and 0 deletions

View File

@ -86,6 +86,11 @@ class ImageExportPlugin extends ServerPlugin {
} }
if ($result = $this->getPhoto($node)) { 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-Type', $result['Content-Type']);
$response->setHeader('Content-Disposition', 'attachment'); $response->setHeader('Content-Disposition', 'attachment');
$response->setStatus(200); $response->setStatus(200);