-2

I am failing the Google and GTmetrix speed tests miserably for my WordPress site. Both specify that browser caching is not enabled.

I have tried a few caching plugins, such as WP Super Cache, but they have had zero effect.

I have also manually edited the .htaccess file with the following:

##### EXPIRE CACHING - LEVERAGE BROWSER CACHING #####
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month 1 days"
ExpiresByType text/html "access plus 1 month 1 days"
ExpiresByType image/gif "access plus 1 month 1 days"
ExpiresByType image/jpeg "access plus 1 month 1 days"
ExpiresByType image/png "access plus 1 month 1 days"
ExpiresByType text/css "access plus 1 month 1 days"
ExpiresByType text/javascript "access plus 1 month 1 week"
ExpiresByType application/x-javascript "access plus 1 month 1 days"
ExpiresByType text/xml "access plus 1 seconds"
</IfModule>
##### END EXPIRE CACHING #####

But, again, it has had zero impact. I have tried my host provider, BlueHost, three times and they have given me a different response each time but they all roughly equate to "nothing to do with us."

Does anyone have an idea what I may be doing wrong?

I feel like I am hitting my head against a brick wall with this one!

I would appreciate any help you can give me.

Ry-
  • 218,210
  • 55
  • 464
  • 476
Sarah
  • 1

2 Answers2

1

I was having the same issue with WP Super Cache (which is how I found this thread). I switched to WP Fastest Cache which solved it for me (it has it as a toggle setting in the options) - thought I'd post just in case you hadn't fixed it yet.

0

The code that you have added will work only when apache module mod_expires is active.

Alternatively, you can use the following code (add it to .htaccess)

# 1 YEAR
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
Header set Cache-Control "max-age=31536000, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
# 1 WEEK
<FilesMatch "\.(txt|xml|js|css)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# NEVER CACHE - notice the extra directives
<FilesMatch "\.(html|htm|php|cgi|pl)$">
Header set Cache-Control "max-age=0, private, no-store, no-cache, must-revalidate"
</FilesMatch>

Please note, that this will leverage browser caching only for internal files, you can't control it for external files.

  • For external files, you can use a `cron`: [Leverage Browser Caching for 3rd Party JS](http://stackoverflow.com/questions/38376871/leverage-browser-caching-for-3rd-party-js/38377857#38377857) – Joe Mar 29 '17 at 22:43
  • Thanks for your help. I tried the code you gave me and that doesn't seem to work either. – Sarah Mar 30 '17 at 08:12