Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leverage browser caching

I have a website and when I check page speed with Google plug-in, I receive:

Leverage browser caching The following resources are missing a cache expiration

Where can I change the settings for this?

like image 799
Daniel Avatar asked Apr 14 '10 00:04

Daniel


People also ask

What is leverage browser caching?

To leverage your browser's caching generally means that you can specify how long web browsers should keep images, CSS and JS stored locally. That way the user's browser will download less data while navigating through your pages, which will improve the loading speed of your website.

What is leverage browser caching WordPress?

About Leverage Browser Caching Leverage Browser Caching means storing static files of a website in visitor browser. And then retrieving them from browser quickly instead again from server. Actually it uses to speed up each page of a website.

How do I fix the leverage browser caching warning in HTML?

To fix the leverage browser caching warning with WP Rocket, all you have to do is install and activate the plugin. That's it. For more details, see our guide on how to properly install and setup WP Rocket in WordPress. WP Rocket will automatically enable browser caching and modify your .


2 Answers

Edit .htaccess and append

<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"
</IfModule>

This link can help you: http://www.quickonlinetips.com/archives/2010/05/leverage-browser-caching-increase-website-speed/

like image 83
MehdiYadollahi Avatar answered Nov 15 '22 05:11

MehdiYadollahi


Leverage Browser Caching

Reduce the load times of pages by storing commonly used files from your website on your visitors browser.

To enable browser caching you need to edit your HTTP headers to set expiry dates on certain types of files.

Find your .htaccess file in the root of your domain, this file is a hidden file but should show up in FTP clients like FileZilla or CORE. You can edit the htaccess file with notepad or any form of basic text editor.

In this file we will set our caching parameters to tell the browser what types of files to cache.

The code below tells browsers what to cache and how long to "remember" it. It should be added to the top of your .htaccess file.

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

Recommendations:

  • Be aggressive with your caching for all static resources
  • Expiry at a minimum of one month
  • Don't set your caching more than a year in advance!

Reference: http://websitespeedoptimizations.com/LeverageBrowserCaching.aspx

like image 21
Ryan Avatar answered Nov 15 '22 04:11

Ryan