How to leverage browser caching in WordPress. In this tutorial, we’ll discuss how to speed up WordPress blog and site by leveraging browser caching via htaccess & plugin.
Caching is one of the best ways to improve the overall performance of a website and blog. Caching static contents (such as Js, CSS, Images etc.) helps to improve the loading time of a webpage. In this article, I’ll discuss different ways to leverage browser caching in WordPress.
What is Browser Caching?
A browser provides a mechanism to store these static resource files on a user local computer. It is known browser caching.Leverage browser caching term means you instructed (via htaccess or using an inbuilt plugin) browsers how their resources should be dealt with.
Advantage of Caching Static Contents
1. Improves load time.
2. Improves SEO ranking – Google hates slow loading website and gives them a lower rank.
3. Save bandwidth.
4. Reduce no. of HTTP request.
5. Better user experience.
How to Leverage Browser Caching in WordPress
1. Leverage browser caching in WordPress via htaccess –
If you are not familiar with htaccess file and their usage and then check complete htaccess tutorial.
To enable browser caching through htaccess. Open your htaccess file and add these directives.
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 application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
That’s all, Now all the static contents (Such as CSS, Js, Images etc) will cache on a user browser.
2. Leverage Browser Caching in WordPress through WordPress Plugin
If you are not comfortable with .htaccess directives then let’s check two most useful plugins for caching. These two plugins are –
a) W3 Total Cache – W3 Total Cache is an awesome plugin. It can give you lot more caching options such as Database Cache, Object Cache etc. But in this tutorial, We will only discuss browser caching.
To enable a browser caching go to Performance -> Browser Cache section. Now just check enable check box.
b) WP Super Cache – WP super cache is another great plugin that cache your files and provide lot more options for better performance of your blog.
To enable caching through WP Super Cache
If you want to go for more performance. Go for advance setting