Search code examples
c#asp.net-mvccache-control

Is it possible to set content expiration on the server (IIS) to force a new script file version to be downloaded?


Having released a new web application, updates are going out fairly frequently. Browsers cache external script and CSS files, and when updated, UI behaviour is not as it should be if the user's browser continues to use a cache version of the script file.

Is it possible to set the server to issue one time cache control headers so that any new requests pull new versions of all files referenced from a URL?

If not, any advice on how to deal with this efficiently?


Solution

  • The ways rails does it is by appending a number to the end of the files as they are referenced. You can append a number to the end of the file, and make the number change with a new build

    <script src="jquery.js?r=2301293123"/>