Skip to content

Limit page cache storage to successful HTML responses #83

@mehul0810

Description

@mehul0810

Finding

The page-cache writer only skips empty output, responses with status code >= 400, and responses that set cookies. It does not require a 200/OK response and does not verify that the response is HTML before writing cache files.

Evidence

  • src/Modules/Cache/PageCache.php store_cache() skips http_response_code() >= 400 but allows 3xx responses and other non-200 statuses.
  • The same method checks for Set-Cookie headers but does not skip Location redirects or non-HTML Content-Type responses before writing metadata and body files.

Impact

Redirects or other non-HTML frontend responses can be captured as page-cache entries. Later visitors may receive stale or incorrect cached output without the original response headers, which can break redirects, plugin endpoints, or theme-level responses.

Suggested fix

Only write cache files for successful cacheable HTML responses. At minimum, require HTTP 200 and skip when Location headers are present. Prefer also checking response Content-Type when available and allowing only text/html.

Acceptance criteria

  • 3xx responses are never written to the page cache.
  • Non-HTML frontend responses are not cached.
  • Normal public HTML pages still cache successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cachePage cache, menu cache, preload, invalidation, observability, or cache settings.area: frontendPublic-facing frontend output, assets, feeds, headers, or visitor behavior.bugConfirmed or likely defect affecting runtime behavior, UX, compatibility, or data handling.priority: highImportant for the next planned release or high user impact.risk: release-blockerShould be resolved or explicitly deferred before the target release ships.status: readyScoped enough for implementation without major open questions.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions