Skip to content

Conversation

@giuscris
Copy link
Member

@giuscris giuscris commented Oct 30, 2025

This pull request updates the page response caching logic in PageController.php to improve cache accuracy and control. The main changes ensure that error pages are never cached, cache headers are generated based on the rendered content, and only cache GET/HEAD requests without query parameters. These improvements help prevent serving outdated or incorrect content.

Caching logic improvements:

  • Error pages are now explicitly excluded from being cached by adding a check for !$page->isErrorPage() to the $cacheable condition.
  • Cache headers (ETag and Last-Modified) are now generated using the rendered page content and its last modified time, instead of the content file path, for more accurate cache validation.
  • The cache save operation now uses an optional cache time from the page configuration ($page->get('cache.time', null)), allowing for configurable cache durations.

Request cacheability refinement:

  • Requests with query parameters are now excluded from caching by updating isRequestCacheable() to require an empty query string.
@giuscris giuscris self-assigned this Oct 30, 2025
@giuscris giuscris added the enhancement New feature or request label Oct 30, 2025
@giuscris giuscris requested a review from Copilot October 30, 2025 22:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR improves page caching logic in the PageController by refactoring cache validation, fixing a typo, and adding additional caching constraints.

  • Restructured the caching logic to separate cache retrieval from content generation
  • Changed ETag generation to use rendered content instead of file path for better cache validation
  • Added checks to prevent caching pages with query parameters and error pages

���� Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@giuscris giuscris marked this pull request as ready for review October 30, 2025 22:51
@giuscris giuscris merged commit 0401523 into 2.x Oct 30, 2025
7 checks passed
@giuscris giuscris deleted the feature/improved-cache-control branch October 30, 2025 23:26
@giuscris giuscris added this to the 2.1.0 milestone Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

2 participants