How to Leverage Browser Caching manually in WordPress via .htaccess

Every time when you test your website speed you see that leverage Browser caching percentage is very low and it affect to your website speed and decrease the score in google page rank and yslow. So Adding expire headers you can improve your webpage speed.

What is leverage Browser Caching?

Leverage cache Reduce the load times of web pages by storing commonly used files from your website on your visitors browser. for simple adding expire header in your   .htaccess   file.

Why leverage Browser Caching?

Every time when a visitor visit your website a browser loads a webpage and it has to download all the web files to properly display the page and it happen all time when user repeat visits your site.  it reduce page load times for repeat visitors, Also helps to improve website page speed and its good for S.E.O.

How To Add Expire Header.

Before add Expire Header install  W3Totalcache plugin and config it correctly. Now Check your speed at

Here i would like to share my own experience before adding expire header and after adding expire header.

Before Adding Expire header my website performance result is

leverage cahe

Now i Just add below code to my  .htaccess  file.

[Note :- Before edit your .htacccess file backup your original .htaccess file]

There are Three types to edityour .htaccess file.

  • Edit via cpanel –> file manage
  • via ftp under your public_html file]
  • Using wordpress plugin – wordpress plugin. [Best for non-technical person
[Simple copy this code and paste to it top of the your .htaccess  file. ]After Adding this Code to .htaccess file my website result improve miracle


As you can see i just test after adding above expire code in .htaccess file it took hardly 3-4 minutes my website result improve leverage browser caching now 95%.

I Strongly Recommend to use MaxCDN to Speed up your website. Read : MaxCDN Review.

I am damn sure after putting this code your .htaccess file your rank website Page speed will improve!


Subscribe and Get Free Daily Wordpress Tips and Tutorial Free!

About Mitul Shah

I just love to working with WordPress and i like to share my knowledge to all over world using this website hope my articles as help to build your blog powerful.


  1. “this is very interesting. thanks. i commend you on your great content and excellent topic choices.”

  2. Hello,
    Thank you for your post! I installed the htaccess plugin, but I’m not sure where on the editor I would add the code? Any help would be deeply appreciated, thanks!

  3. Please disregard my previous email. The error has been fixed. Thank you

  4. Hi Mitul,

    I can Copy this code, Please check in FIrefox.

  5. Hi thank you again for the great article, I added the code to my htaccess editor but then I got an error. Does the code need to be placed before the text “# BEGIN W3TC Browser Cache

  6. I got an error after inserting your code 🙁

    Analysis Error

    The page returned an error: 500 Internal Server Error

    GTmetrix tried to access the page, but your server returned with an Internal Server Error. Check your server and application to ensure that it’s returning a success status code.

    • @mahlerosa Yea i am already using this code and working fine, I clearly said first take backup of your .htaccess file, you have to paste this code top of the .htaccess file.

  7. Hi Mitul, Code works perfect, thanks a lot for this article

  8. your code crashed my website

  9. Hi, I followed your tutorial on how to configure W3TotalCache and now tried to insert this code in my htaccess but each time I do it creates a server error, same as mahlerosa had in previous comment. I removed code and website is fine. I tried putting it at the very top of the file, and also right above # BEGIN W3TC Browser Cache. I have not purchased a CDN yet. Is that causing the problem?

  10. very good idea 😉

  11. Ohh thank God, Finally i found something which i am looking for almost one week. Thanks for taking time to write this. Hope to learn more from you.

  12. Thank you so much! I just found this great article since i’m search this for a couple hours.

    YOu made my day!

  13. my page speed now is 90/100

  14. Awesome! I really understood the crux of it today :)!

  15. Thank you so much Mitul, you saved me a huge headache here

  16. Great! My website is now much faster than before.

  17. doesnt work for me, throws 500 error. looks like godaddy has not mod_expires enabled for apache

    any other way to fix this?

Tell us what you're thinking...

All comments are moderated.

* Denotes required field.


Notify via Email Only if someone replies to My Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.