清除服务器缓存办法

news/2025/2/1 17:55:02/
清除服务器缓存办法//在ashx文件中写方法
/// <summary>/// ServerMgr 的摘要说明/// </summary>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;}}/// <summary>/// 清除服务器缓存/// </summary>public string ClearCache(HttpContext context){IDictionaryEnumerator enumerator = HttpRuntime.Cache.GetEnumerator();List<string> keys = new List<string>();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 "刷新成功";elsereturn "刷新失败!";}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);elseAjaxData.GetAjaxData("https://www.baidu.com/Ashx/ServerMgr.ashx", { Method: 'clearCache' }, function (data) { alert(JSON.stringify(data)); }, null, null);//html 调用
<a href="javascript:$c.frushCache()">刷新网站服务器缓存</a>

 


http://www.ppmy.cn/news/489444.html

相关文章

清除cache

总有很多朋友对于Linux的内存管理有疑问&#xff0c;之前一篇[转]理解Linux的性能日志似乎也没能清除大家的疑虑。而在新版核心中&#xff0c;似乎对这个问题提供了新的解决方法&#xff0c;特转出来给大家参考一下。最后&#xff0c;还附上我对这方法的意见&#xff0c;欢迎各…

linux清除cache的2种方法

今天去面试&#xff0c;被问到linux下如何清除cache&#xff0c;一脸懵逼&#xff0c;因为是真的不知道&#xff0c;但记得用sync命令可以把内存中的数据写入硬盘&#xff0c;就这样说了&#xff0c;面试的技术好像不满意&#xff0c;下来之后查了查&#xff0c;原来还有/proc/…

清除linux中缓存(Cache)

每个 Linux 系统有三种选项来清除缓存而不需要中断任何进程或服务。 &#xff08;LCTT 译注&#xff1a;Cache&#xff0c;译作“缓存”&#xff0c;指 CPU 和内存之间高速缓存。Buffer&#xff0c;译作“缓冲区”&#xff0c;指在写入磁盘前的存储再内存中的内容。在本文中&a…

disk cache(磁盘缓存) 和 memory cache(内存缓存)的区别

disk cache(磁盘缓存) 和 memory cache(内存缓存)的区别 同&#xff1a; 都属于强缓存&#xff0c;现在浏览器缓存存储图像和网页等(主要在磁盘上)&#xff0c;而你的操作系统缓存文件可能大部分在内存缓存中。使用这两个缓存功能&#xff0c;是因为它比从远程的 web 服务器获…

Linux如何清除系统cache

1. drop_caches 在Documentation/sysctl/vm.txt中有如下描述: drop_caches Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory, causing that memory to become free. To free pagecache: echo 1 > /proc/sys/vm/drop_cac…

浏览器Disk Cache磁盘缓存及其协商缓存、及原生App和浏览器实现缓存的差异

浏览器Disk Cache磁盘缓存及其协商缓存、及原生App和浏览器实现缓存的差异 目录 浏览器Disk Cache磁盘缓存及其协商缓存、及原生App和浏览器实现缓存的差异 1、Memory Cache和Disk Cache区别 1.1、Memory Cache 1.2、Disk Cache 1.2.1、Disk Cache的存取举例 1.2.2、Dis…

python selenium2/webdriver自动化测试系列教程!?

以下是 Python Selenium2/WebDriver 自动化测试系列教程&#xff0c;希望能对您有所帮助&#xff1a; 1、安装 Selenium WebDriver 在安装 Python 的基础上&#xff0c;请使用 pip 命令安装 Selenium WebDriver&#xff1a; pip install selenium 2、配置浏览器驱动程序 S…

Android N默认锁屏壁纸的实现

从Android N开始&#xff0c;原生系统增加了锁屏壁纸开关&#xff1a; frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java /** If true, the lockscreen will show a distinct wallpaper */private static final boolean ENAB…