File-based caching no-cache request headers bug
-
Hi
I think I’ve found a bug. In sg-cachepress/core/helper/File_Cacher_Trait.php it has a section to “return boolean True if nocache headers exist, false otherwise.”
As part of the has_nocache_headers() function in this section, on line 225 it has this line of code:
foreach ( apache_request_headers() as $header => $value ) {
I believe this should be apache_response_headers() instead of apache_request_headers() as with the way it currently is if you set the ‘cache-control: no-cache’ header using php in WordPress it will still be cached by the file-based caching.
If it is updated to use apache_response_headers() instead then the file-based caching doesn’t cache pages that have a ‘cache-control: no-cache’ header set via php which seems like it would be the desired behaviour.
The way it currently is also has another quirk where if you have ‘disable cache’ ticked in the network tab in dev tools the browser sends the ‘cache-control: no-cache’ header as part of the get request which bypasses the file-based caching as it is set to bypass the cache based on the request header rather than the response header.
- The topic ‘File-based caching no-cache request headers bug’ is closed to new replies.