0

I have an angular-mvc6 application working hand in hand. There are mvc views as well as plain html views in wwwroot/views/.

The html files are being aggressively cached by either aspnet5 itself or IIS (not sure who). I'd like to disable this kind of caching in development (because obviously I'm always editing the html files then refreshing). I know this is not browser caching, I always do a hard refresh.

I hope this won't have anything to do with IIS, editing web.config is the last thing I want to do in my life right now (more so because I want to disable caching in develpoment only).

EDIT: Adding the following to wwwroot/web.config seems to work:

<location path="views/*">
    <system.webServer>
        <httpProtocol>
            <customHeaders>
                <add name="Cache-Control" value="no-cache" />
            </customHeaders>
        </httpProtocol>
    </system.webServer>
</location>

So this sucks, it solved the issue but how do I enable this only in development? Do I really really have to write web.config transformations again? I'll wait a bit but if there's no other way I'll make this the answer.

mrahhal
  • 3,322
  • 1
  • 22
  • 41
  • try to create a filter to clear the cache in pages ? – Frebin Francis Jan 14 '16 at 06:42
  • I'm honestly not sure how to work with caching in aspne5, the apis seemed to have changed a little bit. I'm inclined to think this is from IIS (I hope it's not). I'll try looking at the StaticFiles middleware. – mrahhal Jan 14 '16 at 06:45
  • see this link http://stackoverflow.com/questions/12948156/asp-net-mvc-how-to-disable-automatic-caching-option – Frebin Francis Jan 14 '16 at 06:47
  • Nope, this is about caching output from mvc actions. here I'm not interacting with mvc at all (it's just an http get request to `/views/page.html`). – mrahhal Jan 14 '16 at 06:48
  • You are returning views from MVC actions ? – Frebin Francis Jan 14 '16 at 06:49
  • I'm just getting the initial page from an mvc action (no issues here). After that, angular just issues http get request to various html views. So this has nothing to do with mvc itself. – mrahhal Jan 14 '16 at 06:50

0 Answers0