<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[张宴的博客]]></title> 
<link>http://zyan.cc/index.php</link> 
<description><![CDATA[Web系统架构与底层研发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[张宴的博客]]></copyright>
<item>
<link>http://zyan.cc/post/270/</link>
<title><![CDATA[清除指定squid缓存文件的脚本[原创]]]></title> 
<author>张宴 &lt;net@s135.com&gt;</author>
<category><![CDATA[Cache与存储]]></category>
<pubDate>Sun, 22 Jul 2007 15:41:21 +0000</pubDate> 
<guid>http://zyan.cc/post/270/</guid> 
<description>
<![CDATA[ 
	　　[文章作者：张宴 本文版本：v1.0 最后修改：2007.08.02 转载请注明出处：<a href="http://blog.zyan.cc" target="_blank">http://blog.zyan.cc</a>]<br/><br/>　　<a href="http://www.squid-cache.org/" target="_blank">Squid</a> web缓存加速软件目前已经是新浪、搜狐、网易等各大网站广泛应用。Squid会在设置的缓存目录下建立多个目录，每一个目录下又建立多个目录，然后才在最里层的目录中存放缓存文件（object）。squid会根据用户请求网页的URL进行哈希，生成缓存文件，存放在某一个目录中。squid启动之后，将在内存中建立一个哈希表，记录硬盘中缓存文件配置的情形。<br/><br/>　　对于类似<a href="http://you.video.sina.com.cn/index.html" target="_blank">http://you.video.sina.com.cn/index.html</a>之类的网页，squid只会生成一个缓存文件。可以用squid附带的squidclient工具清除：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">squidclient -m PURGE -p 80 "http://you.video.sina.com.cn/index.html"</div></div><br/><br/>　　而对于带有参数的网页，例如新浪播客的Flash播放器<a href="http://vhead.blog.sina.com.cn/player/outer_player.swf?auto=0&vid=4469852&uid=1278987704" target="_blank">http://vhead.blog.sina.com.cn/player/outer_player.swf?auto=0&vid=4469852&uid=1278987704</a>，因“?”后面的参数不同，导致URL也不同，squid会生成多个缓存文件，哈希分散存放在不同的目录。如果修改了这个outer_player.swf文件，要更新squid缓存就要去清除不同目录下及内存中的很多个缓存文件，十分麻烦，于是我编写了一个Linux下的shell脚本，去完成这件麻烦的事：<br/><br/>　　脚本文件名：clear_squid_cache.sh（8月2日修正了UC网友“城市中的寂寞”反馈的BUG）<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">#!/bin/sh<br/>squidcache_path="/data1/squid/var/cache"<br/>squidclient_path="/usr/local/squid/bin/squidclient"<br/>grep -a -r $1 $squidcache_path/* &#124; strings &#124; grep "http:" &#124; awk -F'http:' '&#123;print "http:"$2;&#125;' > cache_list.txt<br/>for url in `cat cache_list.txt`; do<br/>$squidclient_path -m PURGE -p 80 $url<br/>done</div></div><br/>　　<strong>注意：</strong>请赋予clear_squid_cache.sh可执行权限（命令：chmod +x ./clear_squid_cache.sh）。请确保脚本所在目录可写。<br/><br/>　　<strong>设置：</strong><br/>　　squidcache_path= 表示squid缓存目录的路径<br/>　　squidclient_path= 表示squidclient程序所在的路径，默认为squid安装目录下的bin/squidclient<br/><br/>　　<strong>用法：</strong><br/>　　1、清除所有Flash缓存（扩展名.swf）：<br/>　　<span style="color: #008000;">./clear_squid_cache.sh swf</span><br/><br/>　　2、清除URL中包含sina.com.cn的所有缓存：<br/>　　<span style="color: #008000;">./clear_squid_cache.sh sina.com.cn</span><br/><br/>　　3、清除文件名为zhangyan.jpg的所有缓存：<br/>　　<span style="color: #008000;">./clear_squid_cache.sh zhangyan.jpg</span><br/><br/>　　<strong>效率：</strong><br/>　　经测试，在DELL 2950上清除26000个缓存文件用时2分钟左右。平均每秒可清除缓存文件177个。<br/>Tags - <a href="http://zyan.cc/tags/linux/" rel="tag">linux</a> , <a href="http://zyan.cc/tags/squid/" rel="tag">squid</a> , <a href="http://zyan.cc/tags/cache/" rel="tag">cache</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment1401</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>你好 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 04 Aug 2008 02:33:30 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment1401</guid> 
<description>
<![CDATA[ 
	client: ERROR: Cannot connect to localhost:80: Connection refused<br/><br/><br/>缓存清理脚本出现的错误信息 不知道哪里出错了<br/>帮忙看一下 谢谢了
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment2281</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>todayboy &lt;todayboy@126.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 20 Dec 2008 06:24:04 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment2281</guid> 
<description>
<![CDATA[ 
	client: ERROR: Cannot connect to localhost:80: Host unknown.<br/><br/>我也有同样的错误，不知是什么原由：<br/>[root@mamiai01 etc]# . clear_squid_cache.sh &nbsp;.jpg<br/>client: ERROR: Cannot connect to localhost:80: Host unknown.<br/>client: ERROR: Cannot connect to localhost:80: Host unknown.<br/>HTTP/1.1 301 Moved Permanently<br/>Server: nginx/0.5.23<br/>Date: Sat, 20 Dec 2008 06:22:33 GMT<br/>Content-Type: text/html<br/>Content-Length: 185<br/>Connection: close<br/>Location: <a href="http://bjdns3.cncmax.cn:8080?HOST=mamiai.cn&amp;R=/mamiai/baby/images/index_81_13.jpg&amp;" target="_blank">http://bjdns3.cncmax.cn:8080?HOST=mamiai.cn&amp;R=/mamiai/baby/images/index_81_13.jpg&amp;</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment2947</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>D &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 03 Apr 2009 07:53:22 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment2947</guid> 
<description>
<![CDATA[ 
	运行squidclient -h ip PURGE <a href="http://ip:port/index.html" target="_blank">http://ip:port/index.html</a><br/>提示 403 forbidden
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment3181</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>xi2008wang &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 06 May 2009 09:03:21 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment3181</guid> 
<description>
<![CDATA[ 
	ls的兄弟, 不是哪个人都能随便清除的.<br/>看一下htcp_clr_access就知道了<br/>默认是拒绝所有人<br/>htcp_clr_access deny all<br/><br/>并且squid在编译时要加上--enable-htcp
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment4819</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>小丑鱼 &lt;lijhroom@126.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 20 Jan 2010 08:48:06 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment4819</guid> 
<description>
<![CDATA[ 
	张老师我觉得你的grep那段结果还是会出来很多不相关的连接，我对你的grep优化了下好像有好转，你看下<br/><br/>grep -aR $1 $squidcache_path/* &#124; strings &#124; grep &quot;^http:&quot; &#124;grep &quot;$1$&quot; &gt; cache_list.txt
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment6257</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>aa &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 29 Jun 2010 08:03:56 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment6257</guid> 
<description>
<![CDATA[ 
	看一下你/etc/hosts是否是正常的<br/>client: ERROR: Cannot connect to localhost:80: Host unknown.<br/><br/>我也有同样的错误，不知是什么原由：<br/>[root@mamiai01 etc]# . clear_squid_cache.sh&nbsp;&nbsp;.jpg<br/>client: ERROR: Cannot connect to localhost:80: Host unknown.<br/>client: ERROR: Cannot connect to localhost:80: Host unknown.<br/>HTTP/1.1 301 Moved Permanently<br/>Server: nginx/0.5.23<br/>Date: Sat, 20 Dec 2008 06:22:33 GMT<br/>Content-Type: text/html<br/>Content-Length: 185<br/>Connection: close<br/>Location: <a href="http://bjdns3.cncmax.cn:8080?HOST=mamiai.cn&amp;R=/mamiai/baby/images/index_81_13.jpg&amp;" target="_blank">http://bjdns3.cncmax.cn:8080?HOST=mamiai.cn&amp;R=/mamiai/baby/images/index_81_13.jpg&amp;</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment6538</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>心远 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 04 Aug 2010 02:51:18 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment6538</guid> 
<description>
<![CDATA[ 
	[root@vps238 bin]# ./clear_squid_cache.sh uggs4sale.com<br/>grep: /dev/kmem: Permission denied<br/>不知道这是什么原因？
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment7484</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>狂奔的鹿 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 21 Dec 2010 07:33:29 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment7484</guid> 
<description>
<![CDATA[ 
	client: ERROR: Cannot connect to localhost:80: Host unknown.<br/>client: ERROR: Cannot connect to localhost:80: Host unknown.<br/><br/>HOSTS文件没有解析localhost&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 打/etc/hosts&nbsp;&nbsp; 添加&nbsp;&nbsp;127.0.0.1 localhost
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment8749</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>dresses &lt;lh286227785@hotmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 26 Jul 2011 02:14:33 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment8749</guid> 
<description>
<![CDATA[ 
	Here are a variety of the empire &lt;a href=&quot;<a href="http://www.romancearound.com/&quot;&gt;dresses&lt;/a&gt;" target="_blank">http://www.romancearound.com/&quot;&gt;dresses&lt;/a&gt;</a>, I want to introduce yourself. The first shoulder chiffon &lt;a href=&quot;<a href="http://www.romancearound.com/bridesmaid-dresses-c-197.html&quot;&gt;bridesmaid" target="_blank">http://www.romancearound.com/bridesmaid-dresses-c-197.html&quot;&gt;bridesmaid</a> dresses&lt;/a&gt; empire style wedding will &lt;a href=&quot;<a href="http://www.romancearound.com/wedding-dresses-trumpet-wedding-dresses-c-180_253.html&quot;&gt;trumpet" target="_blank">http://www.romancearound.com/wedding-dresses-trumpet-wedding-dresses-c-180_253.html&quot;&gt;trumpet</a> wedding dresses&lt;/a&gt;.This Tia cowries, dressed in her wedding day.Chiffon of the empire the best clothes, because they are the size of the drum as complete motion from the wind the site makes it easy to create a plan impression.One romantic flowers floating above shoulder function and help catch the eyes of the cut of the chest and neck problems, so that more comprehensive coverage of physical illusion bust.Clothing do not like big long torso, short legs, or pear-shaped&lt;a href=&quot;<a href="http://www.romancearound.com/bridesmaid-dresses-ankle-length-bridesmaid-dresses-c-197_198.html&quot;&gt;ankle" target="_blank">http://www.romancearound.com/bridesmaid-dresses-ankle-length-bridesmaid-dresses-c-197_198.html&quot;&gt;ankle</a> length bridesmaid dresses&lt;/a&gt; figure.special is also suitable for pregnant brides since the mobility as a dress can accommodate more Many of the abdomen.
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment14162</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>louis vuitton uk &lt;fsf@fdg.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 23 Nov 2011 00:48:03 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment14162</guid> 
<description>
<![CDATA[ 
	This <a href="http://www.louisvuittonoutlets.org.uk" target="_blank">louis vuitton uk</a> for sale belongs to the sounding just what are termed as Louis Vuitton vintage best sellers, many other products and services for the reason that range appearing companies.You will easily notice the unfold zippers of this <a href="http://www.coachoutletstoreonlinefree.com" target="_blank">coach outlet store online</a>. That is the decoration. There are some inside pockets for you as well. They are easy to match your clothes and to carry.Let us inspire your inner beauty with fine <a href="http://www.christian-louboutinsale.org.uk" target="_blank">christian louboutin sale</a>. Purse the elegance in bridal wedding. Enjoy the fashion.
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment17322</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>chanel uk &lt;xiang1234xiangxiang@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 13 Apr 2012 09:14:52 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment17322</guid> 
<description>
<![CDATA[ 
	<a href="http://www.chanelukoutlets.org.uk" target="_blank">chanel uk</a><br/><a href="http://www.burberryukoutletuk.org" target="_blank">burberry uk</a><br/><a href="http://www.poloralphlaurenuks.org" target="_blank">ralph lauren uk</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment17342</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>chanel uk &lt;xiang1234xiangxiang@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Fri, 13 Apr 2012 09:20:20 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment17342</guid> 
<description>
<![CDATA[ 
	<a href="http://www.christianlouboutinukuk.org" target="_blank">christian louboutin</a><br/><a href="http://www.tiffanyuksuk.org" target="_blank">tiffanys</a><br/><a href="http://www.gucciukbeltuk.org" target="_blank">gucci uk</a><br/><a href="http://www.frsaclouisvuittonsac.com" target="_blank">louis vuitton sac</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment18690</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>coach factory outlet &lt;fgf@hotmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 17 May 2012 02:52:07 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment18690</guid> 
<description>
<![CDATA[ 
	Today, following half a century, mentor leather-bases <a href="http://www.coachfactoryoutletao.net" target="_blank">coach factory outlet</a> continues to be the delicate craft of leather-based master is accountable for,Would you like to meet more friends, or go with the times? If yes, <a href="http://www.coachfactoryoutletao.net" target="_blank">coach factory online</a> is opening welcome doors to you.in the market you definitely can find various colorways that are designed in as well as the high quality that applied in. For most of you would like to come. So just come to our <a href="http://www.coachfactoryoutletao.net" target="_blank">coach factory outlet online</a> store to choose one.
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment18691</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>louis vuitton sale &lt;fgf@hotmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 17 May 2012 02:52:15 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment18691</guid> 
<description>
<![CDATA[ 
	Louis Vuitton belt at <a href="http://www.louisvuittonoutletsalea.com" target="_blank">louis vuitton sale</a> is one kind of fashion accessory with high cost performance among the Louis Vuitton accessories.Offering quality LV products with favorable prices, <a href="http://www.louisvuittonoutletsalea.com" target="_blank">louis vuitton outlet</a> store is at your service. Hurry up, or you can not seize the chance.in fact, <a href="http://www.louisvuittonoutletsalea.com" target="_blank">louis vuitton</a> is one of the most famous fashion design master.he opened the fist suitcase shop called after his name.
]]>
</description>
</item><item>
<link>http://zyan.cc/post/270/#blogcomment18692</link>
<title><![CDATA[[评论] 清除指定squid缓存文件的脚本[原创]]]></title> 
<author>coach outlet online &lt;fgf@hotmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 17 May 2012 02:52:21 +0000</pubDate> 
<guid>http://zyan.cc/post/270/#blogcomment18692</guid> 
<description>
<![CDATA[ 
	I heard of <a href="http://www.coachoutletonlineao.net" target="_blank">coach outlet online</a> through the advertisement when I was shopping. And now I often brow the webpage and buy Coach bags online.It is a symbol regarding position not to mention nature.Here I would like to launch a excellent bags pertaining to business men.Which may be <a href="http://www.coachoutletonlineao.net" target="_blank">coach outlet store</a>.<a href="http://www.coachoutletonlineao.net" target="_blank">coach outlet</a> has always been simple,durable style features to win consumers.The products are more flexible,with easy bleaching,wear characteristics,and simply use a damp cloth.
]]>
</description>
</item>
</channel>
</rss>