Leverage Browser Caching in WordPress

Leverage Browser Caching in WordPress

In order to Leverage Browser Caching WordPress, your web server (where your website is hosted) should allow web browser to store visited webpages data temporally on local disk. This is how you will notice a significant improvement in your website loading speed.

To enable it, you need to set content expiry dates by adding Cache-Control and ETag headers in HTTP headers. Cache-Control states about the caching period of a particular file by web browser and Etag is used to verify changes in cached resources and requested resources.

We can set a specific period in months or years to keep cache resources (i.e. HTML, CSS or JS files, images etc.) locally. It is advisable to set expiry dates as per the frequency of changes in resources.

There are two methods to Leverage Browser Caching in WordPress-

– by adding a piece of code in .htaccess file hosted on your server (Apache)
– by using a WordPress plugin.

 

Leverage Browser Caching via htaccess Apache Server

You need to edit your WordPress .htaccess file.
Open the .htaccess file and paste the following code:

# TN Expires Caching Start #
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 1 month"
</IfModule>
# TN Expires Caching End #

 

Leverage Browser Caching WordPress plugin

Download the ‘WP Fastest Cache’ WordPress Plugin via visiting this link.
Activate the plugin.
You will find a new link in side bar of WordPress Dashboard. Go to the plugin settings.
Check on the Browser Caching box as shown in picture and click on Submit button. A massage will be displayed “Options have been saved”, and you are done.

 

leverage-browser-caching-wordpress-plugin