Cha*_*age 3 security asp.net-mvc browser-cache
就我的研究而言,有几个步骤可以确保禁用浏览器缓存.必须设置这些HTTP标头:
Cache-Control: no-cache, no-store, must-revalidate, proxy-revalidate
Pragma: no-cache
Expires: -1
Last-Modified: -1
Run Code Online (Sandbox Code Playgroud)
我发现这可以通过两种方式完成:
方法一:使用web.config文件
<add name="Cache-Control" value="no-store, no-cache,
must-revalidate, proxy-revalidate"/>
<add name="Pragma" value="no-cache" />
<add name="Expires" value="-1" />
<add name="Last-Modified" value="-1" />
Run Code Online (Sandbox Code Playgroud)
方式二:使用_Layout.cshtml中的元标记
<meta http-equiv="Cache-Control" content="no-cache, no-store,
must-revalidate, proxy-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Expires" content="-1" />
Run Code Online (Sandbox Code Playgroud)
我的问题:哪种方法更好?或者,他们同样可以接受吗?这些都与不同的平台有什么关系?哪些浏览器会尊重哪些标题?
此外,如果有的话,请随意添加我错过的任何内容.
| 归档时间: |
|
| 查看次数: |
2188 次 |
| 最近记录: |