Skip to main content
Participant
May 23, 2017
Answered

How do I add a "Leverage browser caching" and "Cache validator"?

  • May 23, 2017
  • 1 reply
  • 579 views

Am trying to optimize my page and it says to add a Leverage browser caching and Cache validator to my .htaccess file. How do I do that/ whats the code for it.

This is what my .htaccess file has on it, I have not edit anything on it. My page is jooel.me .

# Begin cache control #

ExpiresActive on

ExpiresActive off

<FilesMatch ".*">

Header unset Cache-Control

Header unset Expires

Header unset Last-Modified

FileETag None

Header unset Pragma

</FilesMatch>

# End cache control #

This topic has been closed for replies.
Correct answer Nancy OShea

Add this to your .htaccess file.  These are merely recommendations.  Adjust duration & file types to match your particular project needs.  Most people don't use Flash anymore so you may not need it.  Or if you update/change images often,  you may want to reduce the access duration on that file type to something lower than 1 year.  

## 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 ##

1 reply

Nancy OShea
Community Expert
Nancy OSheaCommunity ExpertCorrect answer
Community Expert
May 23, 2017

Add this to your .htaccess file.  These are merely recommendations.  Adjust duration & file types to match your particular project needs.  Most people don't use Flash anymore so you may not need it.  Or if you update/change images often,  you may want to reduce the access duration on that file type to something lower than 1 year.  

## 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 ##

Nancy O'Shea— Product User & Community Expert
Participant
May 24, 2017

Thank you, so do I just copy and paste that anywhere in the .htaccess file?

Nancy OShea
Community Expert
Community Expert
May 24, 2017

Check with your web host. 

Nancy O'Shea— Product User & Community Expert