【发布时间】:2017-08-02 22:04:30
【问题描述】:
我目前正在使用 ASP.NET Web 应用程序(基本 VS2017 MVC 模板),由于需要在两个应用程序之间切换,我需要完全禁用 DNS 缓存浏览器端,并关闭所有打开的连接。目前,即使更改了 DNS 记录,Chrome 和 IE 仍然会路由到应该死的页面。
我尝试过的帖子:
-
How to add .htaccess file to my Visual Studio solutions 与低
cacheControlMaxAge,然后使用cacheControlMode="DisableCache" - How to control web page caching, across all browsers?我使用了 ASP.NET 的建议。
- How can I disable HTTP Keep-Alive in ASP.NET MVC?
对于最后一个,我不确定它是否按预期工作。应用上述每个标题后,我的标题是:
响应标头:
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
请求标头:
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 似乎仍然对请求启用,但我不知道这是否有任何影响。
由于 VS 中的默认设置,我还有两个 Web.config 文件。我一直在对两者进行更改,看看有什么效果。以下是编辑部分:
视图/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>
我最好的猜测是我的浏览器没有重新检查 DNS 记录,因为使用 nplookup 检查它会给出重定向的位置,即使旧页面仍在运行。使用 Wireshark 查看网络流量表明连接保持打开状态,因此这可能是原因。任何关于如何强制浏览器重新检查 DNS 记录的建议将不胜感激。提前谢谢你。
【问题讨论】:
-
你确定你了解什么是DNS,为什么浏览器没有dns缓存,为什么不能通过网站响应控制它?
-
superuser.com/questions/203674/… 我对其他想法持开放态度,但这是我为什么不断被重定向到错误网站的最佳猜测。
-
好的,google 重新发明了轮子并创建了另一个 dns 缓存,但您仍然无法通过网站响应来控制它,因为 dns 在之前实际请求您的网站
-
@IlyaBursov: support.opendns.com/hc/en-us/articles/… superuser.com/questions/367197/… 这似乎只是一个现代浏览器功能。同样,我对问题的其他解释持开放态度,但请在回复之前进行一些研究。
-
@IlyaBursov:我链接到的超级用户帖子引用了微软官方页面,详细说明了 IE 确实如何处理 DNS 缓存。 support.microsoft.com/en-us/help/263558/…
标签: asp.net web-applications dns web-config