【发布时间】:2013-09-12 23:14:56
【问题描述】:
有没有办法以编程方式在回发时删除我的浏览器缓存?我正在使用一个 jquery 函数,该函数在使用 cache:true 的按钮单击时使用 ajax
function CallSyncAjax(url, args, resid, EnableCache, ErrorDivID) {
$.ajax({
type: "GET",
url: url,
data: args,
cache: EnableCache,
success: function (data) {
var StrResponse;
StrResponse = data.split('@@@');
if (resid == "1001") {
LoginByAccountRes(StrResponse[0]);
}
}
})
}
C#:
protected override void OnLoad(EventArgs e)
{
// Set Cacheability...
DateTime dt = DateTime.Now.AddMinutes(1);
Response.Cache.SetExpires(dt);
Response.Cache.SetMaxAge(new TimeSpan(dt.ToFileTime()));
// Complete OnLoad...
base.OnLoad(e);
}
问题是每当我在一分钟后刷新页面,即使我关闭浏览器并重新打开它,缓存仍然存在
【问题讨论】:
-
为什么不试试
DateTime dt = DateTime.Now.AddMinutes(-1);? -
试试
Response.Cache.SetCacheability(HttpCacheability.NoCache); -
因为它不起作用
标签: c# javascript jquery asp.net caching