How to Fix Leverage Browser Caching WordPress In htaccess File

How to Fix Leverage Browser Caching WordPress In htaccess File

What is Leverage Browser Caching?

We browse various types of websites for our own needs. The website consists of like Html, CSS, javascript, images. When every time we are browsing the new website at this time it has downloaded all web files like text, images, script, etc. Some websites might only consist of a few files seems like a couple of kilobytes. In some cases, some websites have a much larger size. If your website has a lot of sizes. You can lose your website rank. Leverage browser caching WordPress many important roles for WordPress. Leverage browser caching storing some of these files and locally browse in the user’s browser.

When you first a visit website and the first time the website takes a few seconds to load in the browser. But the second time when you revisit this site that time quickly and easily loads in your browser. The more data have on your website then you will get more server request. Website data should be more lightweight but you will need to fix leverage browser caching on your WordPress site.

Why is it important or how to check leverage browser caching?

The main reason why browser caching is most important if you reduce the load on your server, for user reduces load time. We suggest & using Google Page Inside or Pingdom website speed test tools. Copy your website link put the google page inside or Pingdom website speed tools if google page inside then clicks ANALYZE and Pingdom click start test.

Google Page Inside result

Pingdom Speed Test

How to Fix Leverage Browser Caching WordPress in with htaccess File

Now we want to show you fix leverage browser caching WordPress site. We can do this in two ways Cpanel method or FTP method (like Filezilla, WinSCP, Transmet) we use FileZilla. First login your Cpanel.

Go to the file manager

Now open the file manager directory then top corner right side settings just click here and check this Show Hidden Files (dotfiles) save.

Then you will see all dot & hidden files in between download and only .htaccess file. If you use FileZilla just put your all FTP information in FileZilla then got to public_html  >> .htaccess drag and download it.

If the download complete .htaccess file open in any code editor and I will add some code for leverage browser caching and do not delete htaccess default code.

 # Leverage Browser Caching
<IfModule mod_expires.c>
  ExpiresActive On
  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 text/html "access 1 month"
  ExpiresByType application/pdf "access 1 month"
  ExpiresByType text/x-javascript "access 1 month"
  ExpiresByType application/x-shockwave-flash "access 1 month"
  ExpiresByType image/x-icon "access 1 year"
  ExpiresDefault "access 1 month"
</IfModule>
<IfModule mod_headers.c>
  <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf)$">
  Header set Cache-Control "max-age=2678400, public"
  </filesmatch>
  <filesmatch "\.(html|htm)$">
  Header set Cache-Control "max-age=7200, private, must-revalidate"
  </filesmatch>
  <filesmatch "\.(pdf)$">
  Header set Cache-Control "max-age=86400, public"
  </filesmatch>
  <filesmatch "\.(js)$">
  Header set Cache-Control "max-age=2678400, private"
  </filesmatch>
</IfModule>

Now we are adding leverage browser caching fixing code and re-upload .htaccess file. Furthermore, We are rechecking Pingdom tool there is no leverage browser caching.

Some this topics related tutorial might help WordPress