Quick question. I'm trying to enable browser caching for a wordpress site on Apache with SSL enabled.
I installed mod_expires with sudo a2enmod expires
(I verified it's enabled and listed on /etc/apache2/mods-enabled)
I edited the .htaccess file as suggested by GTMetrix
My .htaccess (which I verified it's being accessed by uncommenting the rewrite rules and seeing pages going offline) is as follows:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# Browser Caching Start #
<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
# Browser Caching End #
Restarted apache and tested on Google and GTMetrix. I keep getting "leverage browser caching" showing the images expiring in 4 hours.
https.../image.png (4 hours)
Any suggestions as to how to debug this, or are you seeing something I am doing wrong?
Here is the http response header for one of the images:
Content-Length: 13937
Connection: keep-alive
Set-Cookie: __cfduid=dc6febbc08cc78186b2444352064d20611481224874; expires=Fri, 08-Dec-17 19:21:14 GMT; path=/; domain=.mydomain.com; HttpOnly
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Last-Modified: Wed, 07 Dec 2016 05:20:33 GMT
ETag: "3671-5430aae243b0e"
Cache-Control: public, max-age=2592000
Expires: Sat, 07 Jan 2017 19:21:14 GMT
X-Content-Type-Options: nosniff
CF-Cache-Status: MISS
Accept-Ranges: bytes
Server: cloudflare-nginx
CF-RAY: 30e294493e2f3fd7-YUL
I see "Expires: Sat, 07 Jan" so it SHOULD be a month, but Google keeps writing it's 4 hours? What's going on here? :)