From 5841d0a9449cd194b045ee304df4c4afbe5ec959 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Fri, 8 May 2026 09:59:36 +0530 Subject: [PATCH] Inline storage preview cache control --- app/controllers/shared/api.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 3ab2d165a3..0ef58862e7 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -642,7 +642,7 @@ Http::init() $data = $cache->load($key, $timestamp); if (! empty($data) && ! $cacheLog->isEmpty()) { - $storageCacheControl = null; + $cacheControl = \sprintf('private, max-age=%d', $timestamp); $parts = explode('/', $cacheLog->getAttribute('resourceType', '')); $type = $parts[0]; @@ -697,7 +697,7 @@ Http::init() } if ($isImageTransformation) { - $storageCacheControl = new StorageCacheControl( + $cacheControl = $cacheControlForStorage(new StorageCacheControl( source: CacheControl::SOURCE_CACHE, user: $user, maxAge: $timestamp, @@ -709,7 +709,7 @@ Http::init() fileSecurity: $fileSecurity, cacheLog: $cacheLog, route: $route, - ); + )); } } @@ -722,11 +722,6 @@ Http::init() $cache->save($key, $data); } - $cacheControl = \sprintf('private, max-age=%d', $timestamp); - if ($storageCacheControl !== null) { - $cacheControl = $cacheControlForStorage($storageCacheControl); - } - $response ->addHeader('Cache-Control', $cacheControl) ->addHeader('X-Appwrite-Cache', 'hit')