From 707e5d231a80af419aaee26ae5bad696dc993810 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 8 May 2026 09:55:33 +0530 Subject: [PATCH] Scope storage cache control to previews --- app/controllers/shared/api.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 4e4ccc4b52..d404ae501a 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -707,19 +707,22 @@ Http::init() $cache->save($key, $data); } - $cacheControl = $cacheControlForStorage(new CacheControl( - source: CacheControl::SOURCE_CACHE, - project: $project, - user: $user, - bucket: $bucket, - file: $file, - resourceToken: $resourceToken, - maxAge: $timestamp, - isImageTransformation: $isImageTransformation, - fileSecurity: $fileSecurity, - cacheLog: $cacheLog, - route: $route, - )); + $cacheControl = \sprintf('private, max-age=%d', $timestamp); + if ($isImageTransformation) { + $cacheControl = $cacheControlForStorage(new CacheControl( + source: CacheControl::SOURCE_CACHE, + project: $project, + user: $user, + bucket: $bucket, + file: $file, + resourceToken: $resourceToken, + maxAge: $timestamp, + isImageTransformation: $isImageTransformation, + fileSecurity: $fileSecurity, + cacheLog: $cacheLog, + route: $route, + )); + } $response ->addHeader('Cache-Control', $cacheControl)