-
Notifications
You must be signed in to change notification settings - Fork 2k
feat: add configurable status code filtering for PageCache filter
#9856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.7
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick note: an empty array [] currently means cache all status codes, but it might read as cache nothing at first glance. Using something like [Cache::ALL_STATUS_CODES] or ['*'] could make it clearer.
|
I considered it, but storing all status codes in one place seems counterproductive. Using |
I wasn’t suggesting enumerating all status codes. public const ALL_STATUS_CODES = -1;That said, I understand the preference to rely on documentation. |
|
Oh, okay - thanks for the clarification. If more users agree that having something like |
52298aa to
97863a1
Compare
neznaika0
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see the point in adding a constant. The empty array looks correct. In the future, we can update if receive a bug report.
Description
This PR introduces a new configuration property,
Config\Cache::$cacheStatusCodes, which allows developers to explicitly control which HTTP response status codes are cached.This is important because not all responses should be cached by default. In practice, applications may want to cache responses beyond 200 OK (for example, 404), or the opposite - prevent caching of certain status codes to avoid serving stale or misleading responses. Making this configurable gives developers good control over cache behavior.
Minor BC break:
The
PageCachefilter constructor now accepts an optionalCacheparameter to allow dependency injection (primarily for testing). This should not affect most users, as the parameter has a default value and existing usage continues to work unchanged.Checklist: