sam
sam

Reputation: 10094

How to set Browser caching and expires headers via .htacess

Ive got a centOS lamp server running a static html, css, js site. Google's page speed tool suggested i "Leverage browser caching" (as this may be a google seo ranking factor we want to implement it). Is this something that can be done via the .htaccess file of my site ?

Ive set this up in the past but only via a wordpress plugin so it was pretty much one click.

Upvotes: 0

Views: 511

Answers (1)

Polaris
Polaris

Reputation: 712

Try to add this to the top of your htaccess-file:

## 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 text/html "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 1 month"
</IfModule>
## EXPIRES CACHING ##

Upvotes: 2

Related Questions