I'm setting up Apache caching on CentOS using mod_cache
and 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 test is being done using Chrome Incognito browser on a public WordPress page.
The full configuration. CacheRoot exists and is writable for the Apache user.
# The following line could be required or not depending on your Apache installation
LoadModule cache_module modules/mod_cache.so
<IfModule mod_cache.c>
CacheQuickHandler off
CacheDetailHeader on
CacheIgnoreNoLastMod On
CacheDefaultExpire 7200
CacheIgnoreCacheControl On
CacheLastModifiedFactor 0.5
CacheIgnoreHeaders Set-Cookie Cookie
CacheHeader on
CacheLock on
CacheDisable /wp-admin
CacheDisable /wp-login.php
CacheDisable /wp-cron.php
SetOutputFilter CACHE
AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/rss+xml text/xml image/svg+xml
# The following line could be required or not depending on your Apache installation
LoadModule cache_disk_module modules/mod_cache_disk.so
<IfModule mod_cache_disk.c>
CacheRoot /var/cache/apache2/mod_cache_disk
CacheEnable disk /
CacheDirLevels 2
CacheDirLength 1
CacheMaxFileSize 2000000
</IfModule>
</IfModule>
FYI - The reason I'm using mod_cache with WP is that this project is based on the Bedrock framework which doesn't seem to work well with WP Super Cache and other plugins. They recommend using Memcached, Nginx or Varnish, none of which I have access to install.
Update
WP_CACHE
is set totrue
- Added
CacheMaxExpire 86400
to config and theX-Cache-Detail
error changed tos-maxage or max-age zero and no Last-Modified or Etag
and theCache-Control
header is nowCache-Control: private, proxy-revalidate, s-maxage=0
- Added
mod_expires
:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access 1 month"
...
</IfModule>