问题
I came across a problem today where the only way for the web program I am developing showed the most recent copy of a modified script was to reboot the machine. It is a file bundled in the master layout page, in a script bundle. I tried CTRL-F5 and deleted all files (I think) in Internet Options of IE11 to ensure it wasn't using the cached copy, but that was not sufficient.
I then suspected the cause is related to the fact I am using the VS Development server in VS2010. I tried killing WebDev.WebServer40.exe, hypothesizing it was caching it there, but that was not it either. I made the test as basic as modifying the entire contents of the script file to be a single alert() message, which never appeared, until I rebooted the machine.
I've seen suggestions to add args to the file when referencing it, or rename it each build, but clearly that's not productive when running many iterations in new development. I am wondering if there's perhaps a Visual Studio or Internet Explorer option here that guarantees to load the un-cached file each build? Is IE also possibly caching this info in some other memory space I need to be aware of too? thanks
EDIT: Ok, it turns out the root cause of the problem was a post-build step modifying the script files I was working on. Rebooting was therefore a coincidental fix. As always, blame the writer. :). However, I have seen this problem occur many times in the past, genuinely, and am still curious if there's browser settings available (with specifics) that ensure scripts (and CSS files) are never cached, in development.
回答1:
Disable the browser cache. Accessed through the debugger or developer tools (usually F12).
Here are some examples:
Chrome
Firefox
IE11
来源:https://stackoverflow.com/questions/33047794/how-do-i-ensure-my-script-file-isnt-cached-when-debugging-a-vs-mvc-website