I'm currently working with an ASP.NET Web Application (Basic VS2017 MVC template) and due to requirements with switching between two applications I need to completely disable DNS caching browser side, as well as close any open connections. Currently, even after the DNS record is changed, Chrome and IE still route to the should-be-dead page.
Posts I've tried:
- How to add .htaccess file to my Visual Studio solutions with a low
cacheControlMaxAge
, then usingcacheControlMode="DisableCache"
- How to control web page caching, across all browsers? I used the ASP.NET suggestion.
- How can I disable HTTP Keep-Alive in ASP.NET MVC?
For that last one, I'm not sure I have it working as intended. After applying each of the above my headers are:
Response Headers:
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Content-Length: 1079
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Expires: 0
Vary: Accept-Encoding
Server: Microsoft-IIS/8.0
X-AspNetMvc-Version: 5.2
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 02 Aug 2017 21:36:50 GMT
Request Headers:
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:ARRAffinity=789fe7bbe28c722b0920137dba18498fceae0426a05f2d26c581fb12b875c8d9
Host:[redacted]
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
keep-alive
seems to still be enabled for the request, but I don't know if that has any impact.
I also have two Web.config files due to the default setup in VS. I've been putting my changes in both to see what sticks. Below are the edited portions:
views/Web.config:
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
<httpProtocol allowKeepAlive="false" />
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
appName/Web.config
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
<httpProtocol allowKeepAlive="false" />
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
</system.webServer>
My best guess is that my browser isn't rechecking the DNS record, as checking it with nplookup gives the redirected location even while the old page is still up. Looking at the network traffic with Wireshark shows that to connection is kept open, so that would be a likely reason why. Any advice on how I can force a browser to recheck the DNS record would be greatly appreciated. Thank you in advance.