feat: add configurable status code filtering for PageCache filter#9856
feat: add configurable status code filtering for PageCache filter#9856michalsn merged 3 commits intocodeigniter4:4.7from
PageCache filter#9856Conversation
|
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.
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.
bfe136a to
548caa9
Compare
|
Thank you for reviews, everyone! |
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: