Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore cache in IE when running through Visual Studio

I often use IE as my development browser because of its tight integration with Visual Studio. However, every time I start a web project from Visual Studio, I am forced to open the IE dev tools (with F12) and reload the page in order to avoid using cached versions of my code.

Is there a way to tell Visual Studio to open IE with the dev tools already open? Or to open IE with the cache already ignored?

like image 327
Nathan Friend Avatar asked Jan 05 '15 14:01

Nathan Friend


1 Answers

I use Internet Explorer only when debugging with Visual Studio. I changed my settings so that the cookies and cache clear every time I exit IE so I have no trouble when debugging. Obviously, this is not very practical if you actually use IE for anything else, but I use Chrome exclusively for all other purposes so this solution works quite well for me.

  1. Open your Internet Options and check the box that says Delete browsing history on exit

enter image description here

  1. Next, go into your "Delete Browsing History" settings by clicking on the Delete... button under the Browsing history header on the General tab -or- by clicking on Settings icon --> Safety --> Delete Browsing History

enter image description here

  1. Uncheck the box that says Preserve Favorites website data

enter image description here

Now, your cache and cookies will clear automatically when you exit Internet Explorer (and when you stop debugging since it closes the browser)

Note: The screenshots and instructions given are for Internet Explorer 11. Instructions for other versions may vary.

--- EDIT ---

To force IE to load a new file instead of loading it from cache, so you don't have to close the browser and reopen it there's two things you can do.

First - you can go into your Browsing history Settings

enter image description here

and select Every time I visit the webpage under Check for newer versions of stored pages:

enter image description here

If IE decides to work like it's supposed to - then caching is basically disabled and will load a new version of your files every time you visit the page or reload a page.

Another option that I highly recommend and is compatible with all browsers, is to use versioning on your code references to force the page to reload the new file instead of using cache. I use this consistently with every application so I don't get phone calls about something not working correctly after I make a change - just for me to tell them to clear their cache.

This is very simple to do, just add your references like this:

<script src="/scripts/application.js?v1.2.85"></script>

All you need to add is the ?v... at the end of the file name. The browser identifies this as a new version of the file and reloads it instead of using cache. You do not need to actually rename the file, only change how it's referenced in your HTML page. This works for both JavaScript files and StyleSheets.

If you want to get really fancy, you could generate a random unique identifier on the server-side and insert it to your references every time the page is loaded, so the most recent version will always be used.

like image 83
Howard Renollet Avatar answered Oct 01 '22 01:10

Howard Renollet