For a long time I've been updating ASP.NET
pages on the server and never find the correct way to make changes visible on files like CSS
and images
.
I know if a append something in the URL
the browser will think the file is another one:
<img src="/images/myLogo.png?v=1"/>
or perhaps changing its name:
<img src="/images/myLogo.v1.png"/>
Unfortunately it does not look the correct way. In a case were I'm using App_Themes
the files in this folder are automatically injected in the page in a way I can't easily change the URL
.
So my question is:
When I'm publishing de ASP.NET Application
on the server what is the correct way to signal to IIS
(and it notify browser after that) that a file was changed? It is not automatic? Should I change some configuration in IIS
or perhaps make some "decoration" in the code?
I've already tried many questions here in SO like "ASP.NET - Invalidate browser cache", "How to refresh the browser cache of an image?", "Handle cached images? How to get the browser to show the new version?", and even "What is an elegant way to force browsers to reload cached CSS/JS files?" but none of them actually take another aproach else in a way you must handle it manually in the code instead of IIS
or ASP.NET
configuration.
The closer I could find is "Asking browsers to cache our images (ASP.NET/IIS)" where they set expiration but not based on the fact the files were update. Instead they used days or hour to cache those file so they would updated even when no changes were made.
I'm want to know if IIS
or ASP.NET
offers something related to this, automatically send to the browser that the files was changed. Is it possible/built in?