Skip to content

Commit

Permalink
Merge pull request #34316 from nextcloud/backport/34215/stable25
Browse files Browse the repository at this point in the history
[stable25] Add cache header for image endpoint if link previews
  • Loading branch information
blizzz authored Sep 29, 2022
2 parents 1f27bd1 + 4aeb701 commit 904ac63
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/Controller/ReferenceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ public function preview(string $referenceId): Response {
$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;
}
}

0 comments on commit 904ac63

Please sign in to comment.