【问题标题】:show image from cache browser从缓存浏览器显示图像
【发布时间】:2011-09-27 16:46:57
【问题描述】:
  var timestamp = new Date().getTime();
  $("#capLogin").attr("src", "Image/Captcha/CaptchaControl.aspx?id="+timestamp);

  $("#capLogin").attr("src", "Image/Captcha/CaptchaControl.aspx?id="+Math.random());

但在后续应用中仍然显示重复图像

【问题讨论】:

  • 可能页面本身被缓存了,需要使用服务器端代码来防止。

标签: javascript jquery asp.net image


【解决方案1】:

为防止您的页面在浏览器中被缓存,请尝试将这些行添加到header

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="0">

【讨论】:

    【解决方案2】:

    为防止缓存尝试将其添加到 CaptchaControl.aspx 代码的 Page_Load 中:

    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.Cache.SetAllowResponseInBrowserHistory(false);
    Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
    Response.Cache.SetNoStore();
    

    这将向浏览器发送适当的标头,要求它不要缓存内容。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-07
      • 1970-01-01
      • 1970-01-01
      • 2018-04-20
      • 2011-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多