Leverage Browser Caching refers to caching the static files of your WordPress blog in the Visitors browsers for a time period by adding expiry headers, so that if the visitors visits your website again ,there will be no need of downloading the same static files once again, as in about 99.9% cases the static file remains same.
To Leverage Browser caching, you will add expiry headers to the static files. By adding expiry headers you will be able define that when the static files should be downloaded again in the visitors browsers, if they visit your blog regularly.
For Example: If you have stated the expiry header for CSS file 30 days, when a visitors loads your website in the browser, it will download all the static files including the CSS file,now once again he visits your website after 10 days and now once again he will download all the files except the CSS file as you have stated that the expiry header for CSS file as 30 days,that means now it will not download the CSS file for next 30 days once it is downloaded in the visitors browser.
Benefits of Leverage Browser Caching
1.Improves Load time of your WordPress blog for the regular visitors.
2.By caching static files,you reduce the number of HTTP requests for the regular visitors.
3.Lots of search Engine like Google consider this while grading the overall experience of your website.
How To Enable Leverage Browser Caching In WordPress
1.To Enable Leverage Browser caching in WordPress,You will have to add the below piece of code in your .htaccess file.
## EXPIRES CACHING ##
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"
## EXPIRES CACHING ##
As you can see we have declared 1 year for different types of Images and 1 month for other files,you can change them as per your needs to anything.
How to Find .htaccess Files to Enable Leverage Browser Caching in WordPress Blog:
1.Default-If you are using cPanel,open the cPanel and then Navigate to “File Manager” > Tick on “Show Hidden files (dotfiles)” and select “Web Root(public_html)” >> Click on “OK” >> You will see .htaccess there add the above code in it, better add it in the end.
2.Yoast SEO Plugin-If you are using Yoast SEO Plugin you can easily Edit your .htaccess files,Just Navigate to Plugin Settings Tab i.e, SEO tab>Edit Files here you can edit .htaccess files.
3.If you are using Security plugins-Lots of Security Plugins edit the .htaccess files and take over the control to it,In that case you will have to find the settings by yourself however we have used BPS security and if you are also using it,you can edit the .htaccess files in it using the htaccess file editor.
The above method will work for most of the people as they are on shared hosting who are using Apache mostly and the other popular one is NGINX where you can’t apply this method, for that you will have to edit some config file,this tut Enable Leverage browser Caching in NGINX may help you.