I’m setting up Apache caching on CentOS using
mod_cache_disk with the configuration at the bottom of this post but the page is not cached. I included
CacheDetailHeader on to get some debug info.
When I hit the page, the HTTP response shows
X-Cache-Detail: "Expires header already expired; not cacheable" and the Expires header is set to some date in 1981, despite the date being correct.
Date: Mon, 19 Aug 2019 23:39:03 GMT Expires: Thu, 19 Nov 1981 08:52:00 GMT
The full configuration. CacheRoot exists and is writable for the Apache user.
PHP is configured to send cache disabling headers, including the Expires: header you show, on pages which start a session. This date corresponds to the birthday of the PHP developer who implemented this feature.
You can configure this behavior by setting
If you are running WordPress there should not be a need to change this from its default of
nocache, as pages with this header correspond to pages being sent to users logging in or already logged in and thus shouldn’t be cached by Apache anyway. You might change it to
private_no_expire to allow logged in users’ browsers to cache the pages, though.
To test your cache, use an incognito window and hit your WordPress site while logged out.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.