0

Hello I am developing a website on ASP.NET and while developing it I am also testing its behavior and changes. The problem I am facing is some times when I make change on .CSS file those changes does not appear on the browser even when I refresh it or rerun the project but when I run that project on different browser it began to show those changes. If it is a code related or browser related or IDE related please let me know. Thanks

Sulman Rasheed
  • 92
  • 1
  • 13
  • 1
    Browsers cache files so they don’t have to be downloaded again. The answers to this [question](https://stackoverflow.com/questions/118884/how-to-force-the-browser-to-reload-cached-css-and-javascript-files) have a lot of information. While you control how long the files are valid in your server settings, the easiest way to add a version to your file name, such as style.css?v=20210326a. – Rich DeBourke Mar 26 '21 at 05:55

1 Answers1

1

Try hitting ctrl-F5 - that will force a re-load.

Unless you change the name of the css file or other resource, the browser can cache that information for months on end.

In fact, some utilities will even add say a dummy parameter to the linked css file - thus on each build the parameter is updated - and thus the browser will not use the older cached value (but, I not found a great working and easy to use utility that does this).

The other way? Empty your browser cache. So yes, the cache can be a REALLY nasty issue during development. And in fact it can be REALLY nasty when you update your site - users will not see say a modify css file, since it been cached, and with the same name, then users will not see new fixes/style changes or even even things like text alignment that you fixed in the css file.

As noted, in most cases, if you launch a page, then try hitting Ctrl-F5 (I think this works in most browsers). If that fails, then you have to in the browser re-set the cache (empty the cache), and then you see the new changes.

I wish had a better solution, and I wish one could just say:

Ok, please re-set ONE time for all past users - since they will often not see your changes - and you don't have much control with any real great ease to re-set the cached information. There are truck-loads, book sized articles in dealing with this issue, but sadly, there not really a great solution right now. If you want say things like cached css stuff to go away client side? Then you have to change the name of the css file - and that can be painful.

At least during development? Well, let the page load, then try Ctrl-f5 - that works well in most cases.

Albert D. Kallal
  • 42,205
  • 3
  • 34
  • 51