Last Updated on April 20, 2022 by WP Knowledge Hub
What Exactly is Leverage browser Caching?
Caching means storing information locally on your web browser, like a kind of browser memory.
Use GT Metrix to see if your WordPress site takes advantage of browser caching correctly. Type in your site’s URL to check if it works.
Using Leverage Browser Caching with WordPress
You need to use a bit of code in order to leverage browser caching in WordPress. Don’t worry – it’s not difficult.
Getting Leverage Browser Caching to work using the .htaccess file is the easiest and most effective method. All you have to do is access the .htaccess file, add the code and you’re done!
Just follow these steps below:
Firstly, log into your hosting account’s hosting panelm like cPanel (or Plesk, etc.), then navigate to the File Manager. Here, you will find the website’s files. Makes sure to turn on the Hidden File option if you don’t see your .htaccess file in the root.
Add the code below at the end of your .htaccess file:
If you perform changes to the assets more frequently, you can change the expiration period to suit your needs. The purpose of this expiration period is to prevent your visitors from having to re-download the assets too often.
You can switch off ETags to improve loading times because you’ve already set cache-control headers, so you won’t need them; therefore, disable them in your .htaccess file. Add the following code to the .htaccess file:
<IfModule mod_headers.c> Header unset ETag </IfModule> FileETag None
Save the .htaccess file and you are done!