-
-
Notifications
You must be signed in to change notification settings - Fork 1
Write page-cache files atomically to avoid partial cache reads #84
Copy link
Copy link
Closed
Labels
area: cachePage cache, menu cache, preload, invalidation, observability, or cache settings.Page cache, menu cache, preload, invalidation, observability, or cache settings.area: performancePerformance-sensitive behavior, page weight, caching, preloading, or resource hints.Performance-sensitive behavior, page weight, caching, preloading, or resource hints.bugConfirmed or likely defect affecting runtime behavior, UX, compatibility, or data handling.Confirmed or likely defect affecting runtime behavior, UX, compatibility, or data handling.priority: highImportant for the next planned release or high user impact.Important for the next planned release or high user impact.risk: release-blockerShould be resolved or explicitly deferred before the target release ships.Should be resolved or explicitly deferred before the target release ships.status: readyScoped enough for implementation without major open questions.Scoped enough for implementation without major open questions.
Milestone
Metadata
Metadata
Assignees
Labels
area: cachePage cache, menu cache, preload, invalidation, observability, or cache settings.Page cache, menu cache, preload, invalidation, observability, or cache settings.area: performancePerformance-sensitive behavior, page weight, caching, preloading, or resource hints.Performance-sensitive behavior, page weight, caching, preloading, or resource hints.bugConfirmed or likely defect affecting runtime behavior, UX, compatibility, or data handling.Confirmed or likely defect affecting runtime behavior, UX, compatibility, or data handling.priority: highImportant for the next planned release or high user impact.Important for the next planned release or high user impact.risk: release-blockerShould be resolved or explicitly deferred before the target release ships.Should be resolved or explicitly deferred before the target release ships.status: readyScoped enough for implementation without major open questions.Scoped enough for implementation without major open questions.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Finding
Page-cache metadata and body files are written directly to their final paths with
file_put_contents().Evidence
src/Modules/Cache/PageCache.phpwrite_cache_meta()writes JSON metadata directly to the final meta path.src/Modules/Cache/PageCache.phpwrite_cache_body()writes HTML directly to the final body path.read_cache_meta()andread_cache_body()directly against those same final paths.Impact
The request lock prevents duplicate writers for the same key, but it does not prevent concurrent readers from seeing partially-written files. A busy site can serve truncated HTML or ignore freshly-written metadata/body pairs during cache regeneration.
Suggested fix
Write metadata and body to temporary files in the same cache directory, then atomically rename them into place. Write the body before the metadata so a fresh metadata file never points at a missing or partial body file.
Acceptance criteria