How do I leverage browser caching according to Google PageSpeed Insights

How can I leverage browser caching according to Google PageSpeed Insights?
Leverage browser caching for the following cacheable resources (picture , javascript and css files)

Answers

  • This should come out of the box.

  • @hgtonight - Thank you for your comment. I thought that I have to put the code below on the .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 ##
    

    But I am not sure if the code works for Vanilla forum. Does it?

  • @Prosper, sorry, I don't use apache

  • Ok thanks @hgtonight.
    Does anyone know the right code to put on .htaccess file to leverage browser caching according to Google PageSpeed Insights?

  • To Enable Browser Caching You Have To Follow These Instructions

    Login Your Cpanel : Go To Your Hosting Panel or Cpanel.
    Find .htaccess File : Find .htaccess file in root directory.
    Open .htaccess File : Open .htaccess file in your web browser.
    Add IfModule Code : Add IfModule Code in your .htaccess file given below.
    Save .htaccess File : Finaly save .htaccess file.

    <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 application/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>

    Source : http://webdeveloperbareilly.in/blog/seo/leverage-browser-caching.html

  • Try this, it's working for me!


    <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 application/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>


    Source

Sign In or Register to comment.