使用squid内置命令查看squid状况和清除cache部分内容
一. 查看squid状况:
1.
squidclient -t 1 -h localhost -p 80 mgr:info
2.
squidclient -T 1 -p 80 -h localhost mgr:5min | grep -e client_http.req -e client_http.all_median_svc_time -e client_http.miss_median_svc_time -e client_http.hit_median_svc_time
二. 如何清cache:
1.
telnet localhost 80
PURGE /ooxx.html?xx=xx HTTP/1.1
Host: www.php-oa.com
2.
purge -P 1 -p localhost:80 -e “^https://www.php-oa.com/ooxx/”
以下内容为 张宴写的一个shell
脚本文件名:clear_squid_cache.sh(8月2日修正了UC网友“城市中的寂寞”反馈的BUG)
引用
#!/bin/sh
squidcache_path=”/data1/squid/var/cache”
squidclient_path=”/usr/local/squid/bin/squidclient”
grep -a -r $1 $squidcache_path/* | strings | grep “http:” | awk -F’http:’ ‘{print “http:”$2;}’ > cache_list.txt
for url in `cat cache_list.txt`; do
$squidclient_path -m PURGE -p 80 $url
done
注意:
请赋予clear_squid_cache.sh可执行权限(命令:chmod +x ./clear_squid_cache.sh)。请确保脚本所在目录可写。
设置:
squidcache_path= 表示squid缓存目录的路径
squidclient_path= 表示squidclient程序所在的路径,默认为squid安装目录下的bin/squidclient
用法:
1、清除所有Flash缓存(扩展名.swf):
./clear_squid_cache.sh swf
2、清除URL中包含sina.com.cn的所有缓存:
./clear_squid_cache.sh sina.com.cn
3、清除文件名为zhangyan.jpg的所有缓存:
./clear_squid_cache.sh zhangyan.jpg
最后更新:2017-01-04 22:34:32