Browse Source

Add cache header for image endpoint if link previews

Signed-off-by: Julius Härtl <jus@bitgrid.net>
pull/34215/head
Julius Härtl 3 years ago
committed by Vincent Petry (Rebase PR Action)
parent
commit
f4a2ab137b
  1. 6
      core/Controller/ReferenceController.php

6
core/Controller/ReferenceController.php

@ -59,9 +59,11 @@ class ReferenceController extends Controller {
$appData = $this->appDataFactory->get('core');
$folder = $appData->getFolder('opengraph');
$file = $folder->getFile($referenceId);
return new DataDownloadResponse($file->getContent(), $referenceId, $reference->getImageContentType());
$response = new DataDownloadResponse($file->getContent(), $referenceId, $reference->getImageContentType());
} catch (NotFoundException|NotPermittedException $e) {
return new DataResponse('', Http::STATUS_NOT_FOUND);
$response = new DataResponse('', Http::STATUS_NOT_FOUND);
}
$response->cacheFor(3600, false, true);
return $response;
}
}
Loading…
Cancel
Save