]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add cache header for image endpoint if link previews 34215/head
authorJulius Härtl <jus@bitgrid.net>
Fri, 23 Sep 2022 10:42:08 +0000 (12:42 +0200)
committerVincent Petry (Rebase PR Action) <PVince81@users.noreply.github.com>
Wed, 28 Sep 2022 13:21:28 +0000 (13:21 +0000)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
core/Controller/ReferenceController.php

index 2f6ef152d0174f7ec301928c1f3f247d77fddfc0..591d84f3e7ca5e2c896c09ddf07cf5067e03a89f 100644 (file)
@@ -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;
        }
 }