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')