From b38af11f65a4e5d774f3e269dab931df225ccbab Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 23 Apr 2026 12:02:00 +0100 Subject: [PATCH] refactor(cache): drop md5 verification on load Hashing the payload on every cache hit adds measurable CPU on the hottest path without catching realistic failure modes. The write-time guards (source size check + `cache.contentType` prefix on save) already stop bad entries from being written; bit-level corruption of the filesystem blob afterwards is not worth paying md5 per hit to detect. Co-Authored-By: Claude Opus 4.7 (1M context) --- app/controllers/shared/api.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 046a0bd785..a0d0b24c54 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -640,21 +640,6 @@ Http::init() $timestamp = 60 * 60 * 24 * 180; // Temporarily increase the TTL to 180 day to ensure files in the cache are still fetched. $data = $cache->load($key, $timestamp); - // Integrity check: the filesystem blob and the cache document are - // two separate stores. If one drifts (partial write, disk corruption, - // a bad entry that slipped past the save-time content-type guard), - // the md5 we signed at save time will no longer match. Treat as a - // miss and purge so the action re-runs and writes a fresh entry. - if (! empty($data) && ! $cacheLog->isEmpty()) { - $storedSignature = $cacheLog->getAttribute('signature', ''); - if (! empty($storedSignature) && \md5($data) !== $storedSignature) { - $cache->purge($key); - $storageCacheOperationsCounter->add(1, ['result' => 'corrupt']); - Span::add('storage.cache.corrupt', true); - $data = false; - } - } - if (! empty($data) && ! $cacheLog->isEmpty()) { $parts = explode('/', $cacheLog->getAttribute('resourceType', '')); $type = $parts[0];