Browser caching.

Today, I would like to speak a few things about browser caching/leverage browser caching and the reason why we must not use it and the most effective way to turn it off completely.

Alright…No doubt, browser caching improves page speed in the browser and how does it happen actually, is it the real page speed of that website when the browser caching is enabled? The real page speed could be a lot slower than usual and here browser caching helps to speed up the page loads. Browser caching stores all the necessary things in the browser and it shows all the pages from those stored copies. This can create a serious problem. I talked about it in a few posts here earlier though, 1) “A better pluginand 2) “Leverage browser caching“.

Once when you will add/update/delete something and the browser caching is turned on, it is you who is seeing the changes in your website on that same browser where you develop that website or it is the browser where you have got the dashboard of that website (for example, a WordPress dashboard) but the old users who previously visited your website from different locations, are not seeing those changes and whenever they visit your website, they are often/always displayed only those old cached/stored copies from the past. Until users clear the browser cache from “all-time”, this problem is not solved and at this point, you cannot explain users about this problem as well, it is because updates are not reaching to the old users who were affected by this browser caching. New users or a new browser will receive the updates but after a while, it would be affected by the browser caching as well. Where do I need a browser caching let’s see. For example, I have a website completely ready and I would never make any changes to this website anymore. It means it is a website that is truly fixed with the fixed contents forever which will never change and nothing would be added/deleted/updated there and there would be nothing latest. In such cases, browser caching/leverage browser caching can improve performance and speed significantly. Once again, it is not any real page speed of that website. 

Yes, here is the easiest but the most effective way to turn browser caching/leverage caching completely off, and to do that we will add the following lines at the bottom of the .htaccess file. It effectively helps in many ways, one of the examples, you have a caching plugin installed and that activated browser caching, in that case, these lines below in the .htaccess file would naturally deactivate that browser caching from that plugin. It might show that the browser caching is enabled in the plugin’s “settings” but in reality, after adding these lines to the .htaccess file, browser caching will not work anymore, regardless of where it is coming from. 

So, let’s add these following lines to the .htaccess file and these would be placed at the bottom of the .htaccess file.

<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, max-age=0, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0

<IfModule mod_expires.c>
ExpiresActive Off

Note: After adding these lines to the .htaccess file, please clear browser cache from “all -time”.

These are the lines above, would definitely rescue you in this situation and instantly. 

All the best and enjoy.

(Please see related posts below)

2 thoughts on “Browser caching.

  • April 15, 2019 at 9:31 pm

    Amazing website and the contents are brilliant, it is the first time I have seen a website that is truly different. One thing you are missing on this website is a donate button. I want to donate here for your future development.

    • April 18, 2019 at 9:32 am

      Thank you “Jane smith”, I wanted to add a donate button but I was always stuck with my work. I would add a donate button.


Leave a Reply

Your email address will not be published. Required fields are marked *