Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET - Overriding Javascript and Styleheets cached by browser

I'm working on an asp.net website. I need to make sure my javascript and css updates will be immediately available for returning visitors, without them having to clear their cache to get the latest code. How can I force this when needed, and leave it alone on other occasions?

Thanks in advance.

like image 867
nokizon Avatar asked Feb 10 '26 16:02

nokizon


1 Answers

Stackoverflow does this very elegantly IMO. You can see in there source there is a query-string variable passed.

<script type="text/javascript" src="http://sstatic.net/js/stub.js?v=778aaf5a38e2"></script>

This will force new load if that changes.

like image 62
Dustin Laine Avatar answered Feb 12 '26 14:02

Dustin Laine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!