Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

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

New Here ,
May 23, 2017 May 23, 2017

Copy link to clipboard

Copied

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 #

Views

484
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 23, 2017 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/g

...

Votes

Translate
Community Expert ,
May 23, 2017 May 23, 2017

Copy link to clipboard

Copied

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 & Moderator

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

Check with your web host. 

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 24, 2017 May 24, 2017

Copy link to clipboard

Copied

LATEST

Ok, thank you very much again.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines