160
中電雲集
使用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