Support Forum

Leverage Browser Caching

ME Meztli
Meztli
Member

Hello guys,

I am trying to speed up my site and one of the things is to implement leverage browser caching via htaccess. But i am a bit unsure if this will have negative impact at my forum.

Please look at the htaccess code below and tell me what you think!

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##

4 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

Well I am not that well acquainted myself with htaccess rules but I do not see anything that looks like an obvious problem.

Worth noting that WordPress tends to append the wp version number to CSS and Javascript files when loading them which, I believe, means they are forced to be re-loaded when the version number changes. I would assume that these htaccess rules will not override that mechanism.

MP Mr Papa
Mr Papa
Member

yeah, the only one I would question is the expires of the js…  if you update any wp core, plugins or themes, you might want to force it…

ME Meztli
Meztli
Member

Thank you for the advice guys.

I removed all lines except those below and it seem to work fine. GTmatrix/Pingdom and Google is happy now and giving my site better page speed and yslow rating.

## EXPIRES CACHING ##

<IfModule mod_expires.c>

ExpiresActive On ExpiresByType image/jpg “access 1 year”

ExpiresByType image/jpeg “access 1 year”

ExpiresByType image/gif “access 1 year”

ExpiresByType image/png “access 1 year”

ExpiresByType image/x-icon “access 1 year”

</IfModule>

## EXPIRES CACHING ##

I really recommed leverage browser chaching and gzip compression via the htaccess file.

Cheers