On WordPress the most first thing we have to do is optimize the speed and make our blog user friendly so that it can also be accessed via slow internet connection. For finding where our site lags, we also uses some tools like Google Pagespeed, GTmetrix, Pingdom etc. You can read our full WordPress Optimization Guide. But here we are just going to see how to enable leverage browser caching in WordPress.

Leverage Browser Caching in WordPress

  1. The first step is to find your .htaccess file which is located in the root directory of your WordPress installation.
  2. Take a backup of your .htaccess file, in case something goes wrong you can replace the file to keep everything working.
  3. Open up .htaccess file.
  4. First thing that you need to do is to get rid of Etag. This is because after disabling Etag, browser needs to rely on cache-control and expires header that is defined by you. For doing so add the following code to your .htaccess file:
  5. Now after disabling Etag. You need to specify expiry headers for the static content like CSS, JS, images, PDFs etc. For that add the following code:
  6. Further you can optimize the content delivery by compressing components of your pages. For this to work you need to have mod_deflate or mod_gzip installed on your hosting server. Now add the following code:
  7. Now save your .htaccess file.

So that’s it you have successfully added Leverage Browser Caching to your WordPress site. You can check whether this worked or not by using various speed test sites(Some we mentioned earlier in the beginning).

Also read: Defer Parsing of JavaScript in WordPress

Thank you for reading this post and keep connected to Tech Arrival to continue enjoying wonderful posts. Share your views about this post in comment section below. If you are still having any query throw it in comment section.

If you find this post helpful, don’t hesitate to share this post on your social network. It will only take a moment and also it is quite easy and helpful for others.


CommentLuv badge