[CDN 技术] 使用squid内置命令查看squid狀況和清除cache部分内容

Mar 3rd, 2008

转载本站文章请注明,转载自:扶凯[http://www.php-oa.com]

本文链接: http://www.php-oa.com/2008/03/03/squid-purge-cache.html

一. 查看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 "^http://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

Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪 ViVi 365Key 网摘 天极网摘 和讯网摘 博拉网 POCO 网摘 饭否 QQ 书签 Digbuzz 我挖网 Mister Wong
No comments yet.