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) <noreply@anthropic.com>
This commit is contained in:
loks0n
2026-04-23 12:02:00 +01:00
co-authored by Claude Opus 4.7
parent 957a588786
commit b38af11f65
-15
View File
@@ -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];