显示缓存浏览器中的图像

show image from cache browser

本文关键字:图像 浏览器 缓存 显示      更新时间:2023-09-26
  var timestamp = new Date().getTime();
  $("#capLogin").attr("src", "Image/Captcha/CaptchaControl.aspx?id="+timestamp);

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

但它仍然在连续的应用程序中显示重复的图像

要防止页面缓存在浏览器上,请尝试将这些行添加到header:

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

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

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

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