Response.CacheControl无法在firefox或chrome中运行

时间:2010-01-15 22:05:20

标签: asp.net caching response

我在global.asax.vb中有此代码,以禁用后退按钮。

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
    Response.Buffer = True
    Response.ExpiresAbsolute = Now().Subtract(New TimeSpan(1, 0, 0, 0))
    Response.Expires = -1
    Response.CacheControl = "no-cache"
End Sub

此代码在IE中运行良好,但拒绝在任何其他浏览器中工作,如firefox或chrome。我该怎么做才能使它成为多浏览器?

1 个答案:

答案 0 :(得分:1)

您可能需要参考this article。它给出的答案是同时使用“no-cache”(对于IE)和“no-store”(对于Firefox)。使用“禁止存储”的原因是:“缺少无缓存支持仅限于Firefox 3.0的早期版本,并且是由一个错误引起的。虽然,现在只有no-cache应该可以使用,但访问者可能会您的网站将运行受影响的Firefox版本。“