Dealing with browser caching and updated script files
-
I encounter this issue fairly regularly at work, and I'm interested in learning about how others handle it. Basically, when you have a Web app and you make some changes to a JavaScript file, how do you ensure that the correct script is loaded when users navigate to the updated Web app? We're using ASP.NET MVC, IIS 7. I've done some digging online and a common solution seems to be appending some sort of identifier to script files in the markup, like this:
Where 'v' is maybe a version number or something along those lines, updated with each deployment. I came across a StackOverflow post in which someone provided a custom HtmlHelper method to append the file's 'LastWriteTime'. But I was wondering how you all handle this. Thanks in advance!
djj55: Nice but may have a permission problem Pete O'Hanlon: He has my permission to run it.
-
I encounter this issue fairly regularly at work, and I'm interested in learning about how others handle it. Basically, when you have a Web app and you make some changes to a JavaScript file, how do you ensure that the correct script is loaded when users navigate to the updated Web app? We're using ASP.NET MVC, IIS 7. I've done some digging online and a common solution seems to be appending some sort of identifier to script files in the markup, like this:
Where 'v' is maybe a version number or something along those lines, updated with each deployment. I came across a StackOverflow post in which someone provided a custom HtmlHelper method to append the file's 'LastWriteTime'. But I was wondering how you all handle this. Thanks in advance!
djj55: Nice but may have a permission problem Pete O'Hanlon: He has my permission to run it.
For example, read this Strategies for Cache-Busting CSS | CSS-Tricks[^] also see ASP.NET Performance | Cache busting using assembly version for RequireJS / ASP.NET MVC projects[^] and What is cache busting? - Curtis Timson[^] Hope they help.
-
For example, read this Strategies for Cache-Busting CSS | CSS-Tricks[^] also see ASP.NET Performance | Cache busting using assembly version for RequireJS / ASP.NET MVC projects[^] and What is cache busting? - Curtis Timson[^] Hope they help.