How to leverage browser caching in WordPress. In simple words, You can say how to cache WordPress static contents in a user browser.
Caching is one of the best ways to improve the overall performance of a website/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 how to cache static contents of your WordPress blog in a user browser.
What is static Contents ?
Advantage of Caching Static Contents in a User Browser
So, If you cache these files in a user browser, think about how much bandwidth and downloading time you can save when user visit again on your website.
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. Cache Static Contents through htaccess –
If you are not familiar with htaccess files 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 start cached on 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