Ever heard about what browser caching is?
Let me explain it to you. Browser caching is a technique to load your blog’s pages faster. In simple words, this definition is apt.
Now let us take a look on how we can use it to make our WordPress blog load faster. Though, we can use this to make any blog or site load faster, we will concentrate completely on the WordPress blogs here.
For a WordPress blog, there are two ways by which we can leverage browser caching and decrease the load time of the pages.
2 Ways to Leverage Browser Caching For WordPress Blog
Before I start with the actual methods, you need to know that these two methods add an expires header to your blog which includes the expiration time set by your server for a particular file.
In other words, expires header will decide that for how much time a file will be cached by the server.
So let’s start with the two techniques now.
- Using .htaccess :- The first and easiest way to do this is to add the below code to your .htaccess file.
Just add this code immediately after “#BEGIN WordPress” line in your .htaccess file. The expiration time mentioned in this code is 2592000 seconds( 30 days). You can change this value according to your needs. What this code does is that it will match the files of the type .ico|flv|jpg…|css… and those files will be stored in the browser’s cache for 30 days. This will stop the visitor’s browser to make requests for these files to your server for every page. This will result in faster loading of your web pages and lesser load on the server.
- Using WordPress Plugin W3 Total Cache :- You can use W3 Total Cache to mention “expires header lifetime” to your blog. Follow the below steps to complete the procedure.
- Download and install W3 Total Cache.
- In the “Performance” menu, go to General Settings and activate “Page Cache” and “Browser Cache”.
- In the “Browser Cache” settings, enable “Set Expires Header”.
- Write down the values in “Expires Header Lifetime” like 2592000 seconds or whatever your need is.
- Do this for “CSS and JS”, “HTML and XML” and “Media and other files”.
( The above mentioned settings are only for adding expires header lifetime to your blog.)
Are you using expires header for your blog? What is the time you prefer to cache your files for? Do let me know if I have missed anything.