서버 캐시 지우기 방법

2139 단어
 

// 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  
웹 서버 캐시 새로 고침
		
		
		

좋은 웹페이지 즐겨찾기