清除服务器缓存办法

清除服务器缓存办法//在ashx文件中写方法 /// /// ServerMgr 的摘要说明 /// public class ServerMgr : IHttpHandler {public void ProcessRequest(HttpContext context) { object returnObj = ""; string method = context.Request["Method"]; switch (method) { case "clearCache": returnObj = ClearCache(context); PageHelper.ReturnAjaxData(context,returnObj.ToString()); break; default: PageHelper.ReturnAjaxData(context,"操作失败!"); break; } }/// /// 清除服务器缓存 /// public string ClearCache(HttpContext context) { IDictionaryEnumerator enumerator = HttpRuntime.Cache.GetEnumerator(); List keys = new List(); while (enumerator.MoveNext()) { keys.Add(enumerator.Key.ToString()); } for (int i = 0; i < keys.Count; i++) { HttpRuntime.Cache.Remove(keys[i]); } if (HttpRuntime.Cache.Count == 0) return "刷新成功"; else return "刷新失败!"; }public bool IsReusable { get { return false; } } } }//js文件 var $c = new Object(); $c.frushCache = function () { if (confirm("确定清除缓存?")) if (window.location.host.indexOf("localhost") > -1) AjaxData.GetAjaxData("http://localhost:8088/Ashx/ServerMgr.ashx", { Method: 'clearCache' }, function (data) { alert(JSON.stringify(data)); }, null, null); else AjaxData.GetAjaxData("https://www.baidu.com/Ashx/ServerMgr.ashx", { Method: 'clearCache' }, function (data) { alert(JSON.stringify(data)); }, null, null); //html 调用 刷新网站服务器缓存

【清除服务器缓存办法】

    推荐阅读