다음을 통해 공유


How to disable caching when doing JavaScript development

I spent a lot of time trying to figure out how to debug my JavaScript while doing SharePoint development using the ECMAScript Client-side object model (CSOM). First I tried forcing it to the Internet Explorer 9 InPrivate mode. This worked, but I couldn't get it to launch from IE this way. I also tried the IE Developer Tools. This failed too as I always had to enable the "Always load from server" on every debugging session. This meant if I had a breakpoint set, I would have to switch back over and hit continue to let it load all the way, then enable the setting, then reload the page. This was getting frustrating.

I ended up solving this, by setting content to expire immediately on the IIS site I was debugging. This technique will work for other technologies as well. Like MVC, ASP.NET, or vanilla HTML, JavaScript and CSS.

To do this load the Internet Services Manager and then expand sites and click on the site you are debugging. Next double click on "HTTP Response Headers". In the top right of the window click on "Set Common Headers…" Check the box for "Expire Web Content", then select "Immediately". It should take effect immediately, but just in case you can recycle the Application Pool.

Next delete your Temporary Internet Files and reload the page. This will ensure that all of the pages get loaded fresh from the server with the new content expiration headers in place.

I hope this helps someone else, and if anyone has a better solution, please let me know.