Are you looking for an option to make your WordPress site run faster? Of course, you may be checking out several options that can help you make your website run faster.
One of the best ways you can run your WordPress site faster is to opt for Browser Caching. So how can you leverage browser caching for good site performance? Let us check out the best options to leverage browser caching and ensure a good optimization performance.
- What is Browser cache and How does it Work?
- How to Leverage Browser Caching using WordPress Plugins? (Easier Method)
- How to leverage browser caching with .htaccess in WordPress? (Coding Method)
- Turn off ETags
- In Conclusion
What is Browser cache and How does it Work?
When your readers visit your website, the browser sends a request to the server to fetch the requested content. The content can include practically anything – images, text, HTML pages, Scripts, and CSS. Depending on the size of the requested content and the server speed, there will be a time required to respond. In case, this speed is too much; the visitors will experience a slowed down response.
This is where Browser cache comes to the fore. It stores the static content on the browser so that the content can be loaded faster next time the user loads the page. If you have not configured your site as per the proper schedule, you will get a warning to leverage your browser cache on the test tools you use to test the load speed of your website.
Leveraging browser caching will help you in reducing the server load times, and it improves the server response time also. You can check your website performance with the tools like Google PageSpeed Insights or Think With Google.
So how would you leverage browser caching? The best option you can use to leverage browser caching is through the .htaccess file. Let us check out how you can do it.
How to Leverage Browser Caching using WordPress Plugins? (Easier Method)
WordPress is indeed a treasure house of plugins. There are plugins to leverage browser caching as well. In any case, we would prefer the option of using the .htaccess file and using it instead of using any plugin.
However, if you are not confident of editing the .htaccess file and are wary of using the option – it may be a good idea to opt for the plugin. We will discuss three most important plugins that can help you leverage browser caching.
Browser Caching with .htaccess
This is one of the popular plugins and available for free in the WordPress repository. One of the lightweight plugins, it does exactly what it claims. The plugin has a five-star rating and is reliable enough.
The plugin does not come with many complicated settings. This makes it best suited for all your needs and it does perform the same tasks we outlined in the above steps.
W3 Total Cache
The W3 cache Plugin is a popular plugin for most of your website cache requirements. It can also be used for all your needs in leveraging browser caching in WordPress.
The plugin has settings for configuring all required things with ease. Just the way we used the editing option for the .htaccess file in the previous steps, the plugin optimize the file on its own.
WP fastest Cache
This is the most recommended plugin for leveraging browser caching. The plugin boasts over 300,000 installations and has a five-star rating.
You can get the plugin from the WordPress repository for free. Install the plugin, activate it and configure the checkbox for browser caching. The plugin will handle the tasks easily.
How to leverage browser caching with .htaccess in WordPress? (Coding Method)
There are different ways you can leverage browser caching, and one of the best ways of caching is by enabling the option for leveraging browser cache.
You will need to configure expiry times for the resources like images and other CSS files. This would require you editing your .htaccess file. The file is found in the root of your hosting server. You can do it by changing the expire headers to improve the performance.
But before you can edit your .htaccess file, you will need to open it. There are two ways you can edit your .htaccess file – using your cPanel or using Yoast plugin.
Here is how you can edit the .htaccess file using cPanel.
- Login to your cPanel.
- Look for the File Manager and launch it.
- Go to the Settings option and enable hidden files
- Locate the root directory of your website.
- You should find your .htaccess file on the public_html folder under your root directory.
- Right click on the .htaccess file and follow the instructions to edit your file.
Alternatively, the Yoast plugin on your WordPress has an option to edit your .htaccess file.
So, what kind of changes would you need to make to your .htaccess file? Let us check out the changes here.
Change Request headers to use cache
Open your .htaccess file through any of the options outlined above and add the following code to the beginning of the file.
Configuring an expiry period of one year is a good option. You can configure any value between one month to one year. Anything beyond these two extremes may not be advisable.
This is the most important option to leverage browser caching on your website.
Add Cache-Control Headers
Once you have added the option to use request headers to use the cache as in the above step, the next one is to add the following code to the .htaccess file. This will add Cache-Control headers.
Edit your .htaccess file and add the following code
The code lets you add the expiry times to the cache control headers, but it would not be needed. You have already added the expiry times as in the above tutorial.
Next action will be to turn off the ETags off.
Turn off ETags
Since we have configured the site to control the cache through Cache-Control headers, you will no longer need ETags. So, we will turn them off with the following code added to your .htaccess file.
Improving your website performance is important. In fact, it has a great bearing on your SEO ranking and site performance as well. No matter which option you would want to use for leveraging the browser cache, it is important to ensure that you have enabled it.
Which of the above methods have you enabled for leveraging browser cache? If you haven’t given a thought to it as yet, it is high time you work on the settings.