¶ÔsquidÖÐrefresh_patternµÄһЩÀí½âºÍ½¨Òé

5年以前  |  阅读数:363 次  |  编程语言:PHP 

refresh_patternµÄ×÷ÓÃ:
ÓÃÓÚȶ¨Ò»¸oÒ³Ãae½øÈecacheºo£¬ËuÔÚcacheÖÐÍ£ÁoµÄʱ¼a¡£refresh_pattern¹aeÔo½o½oÓ¦Óõ½Ã»ÓÐÃ÷ȹýʱÆÚÏÞµÄÏiÓ¦¡£Ô­Ê¼þÎñÆ÷ÄÜʹÓÃExpiresͲ¿£¬»oÕßCache-Control:max-ageÖ¸ÁiÀ´Ö¸¶¨¹ýʱÆÚÏÞ¡£
Ói¨£ºrefresh_pattern [-i] regexp min percent max [options]
min²ÎÊýÊÇ
ÖÖÓÊýÁ¿¡£ËuÊǹýʱÏiÓ¦µÄ×iµÍʱ¼aÏÞÖÆ¡£Èç¹uij¸oÏiӦפÁoÔÚcacheÀiµÄʱ¼aûÓг¬¹ýÕa¸o×iµÍÏÞÖÆ£¬ÄÇôËu²»»a¹ýÆÚ¡£ÀaËƵģ¬max²ÎÊýÊÇ´ae»iÏiÓ¦µÄ×i¸ßʱ¼aÏÞÖÆ¡£Èç¹uij¸oÏiӦפÁoÔÚcacheÀiµÄʱ¼a¸ßÓÚÕa¸o×i¸ßÏÞÖÆ£¬ÄÇôËu±ØÐe±»Ë¢Ð¡£
ÔÚ×iµÍºÍ×i¸ßʱ¼aÏÞÖÆÖ®¼aµÄÏiÓ¦£¬»aÃae¶ÔsquidµÄ×iºoÐÞ¸ÄϵÊýLM-factorËa¨LM-factor=(response age)/(resource age)¡£¶ÔÕaÑuµÄÏiÓ¦£¬squid¼ÆËaÏiÓ¦µÄÄeÁaºÍ×iºoÐÞ¸ÄϵÊý£¬È»ºo½«Ëu×÷Ϊ°ÙÖ±ÈÖµ½øÐбȽϡ£ÏiÓ¦ÄeÁa¼oµ¥µÄ¾ÍÊÇ´ÓԭʼþÎñÆ÷²uÉu£¬»o×iºoÒ»´ÎÑeÖ¤ÏiÓ¦ºo£¬¾­ÀuµÄʱ¼aÊýÁ¿¡£Ô´ÄeÁaÔÚLast-ModifiedºÍDateͲ¿Ö®¼aÊDz»Í¬µÄ¡£LM-factorÊÇÏiÓ¦ÄeÁaÓeÔ´ÄeÁaµÄ±ÈÂÊ¡£
³£Óõļ¸¸o²ÎÊýµÄÒa˼

override-expire
¸ÃÑ¡Ïiµ¼ÖÂsquidÔÚ¼i²eExpiresͲ¿Ö®Ç°£¬Ïȼi²eminÖµ¡£ÕaÑu£¬Ò»¸oÇÁaµÄminʱ¼aÈÃsquidµ»ØÒ»¸oδÈÈϵÄcacheÃuÖУ¬¼´Ê¹¸ÃÏiӦ׼±¸¹ýÆÚ¡£

override-lastmod
¸ÄÑ¡Ïiµ¼ÖÂsquidÔÚ¼i²eLM-factor°Ù*Ö±È֮ǰÏȼi²eminÖµ¡£

reload-into-ims
¸ÃÑ¡ÏiÈÃsquidÔÚÈÈÏÇeÇoÀi£¬ÒÔno-cacheÖ¸Ái´«ËÍÒ»¸oÇeÇo¡£»»¾a»°Ëµ£¬squidÔÚת¢ÇeÇo֮ǰ£¬¶Ô¸ÃÇeÇoÔo¼ÓÒ»¸oIf-Modified- SinceͲ¿¡£×¢ÒaÕaµa½o½oÔÚÄ¿±eÓÐLast-Modifiedʱ¼a´Áʱ²ÅÄܹ¤×÷¡£ÍaÃae½øÀ´µÄÇeÇo±£Áono-cacheÖ¸Ái£¬ÒÔ±aËuµ½´iԭʼþÎñÆ÷¡£
Ò»°aÇe¿o¿ÉÒÔʹÓà reload-into-ims¡£ËuÆaʵÊÇÇ¿ÐпØÖƶÔÏoµÄ³¬Ê±Ê±¼a£¬ÕaÎ¥*´ÁËhttpЭÒeµÄ¾«Éñ£¬µ«ÊÇÔÚ´ø¿i½ÏÕ­µÄ³¡ºÏ£¬¿ÉÒÔÌa¸ßÃ÷ÏÔϵͳÏaӦʱ¼a¡£
¾ÙÀý£º
refresh_pattern -i \.css$ 1440 50% 129600 reload-into-ims
refresh_pattern -i \.xml$ 1440 50% 129600 reload-into-ims
refresh_pattern -i \.html$ 1440 90% 129600 reload-into-ims-
refresh_pattern -i \.shtml$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.hml$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.jpg$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.png$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.gif$ 1440 90% 129600 ignore-reload
refresh_pattern -i \.bmp$ 1440 90% 129600 reload-into-ims
refresh_pattern -i \.js$ 1440 90% 129600 reload-into-ims

ignore-reload
¸ÃÑ¡Ïiµ¼ÖÂsquidºoÂÔÇeÇoÀiµÄÈκÎno-cacheÖ¸Ái¡£
ËuÒÔ¡£Èç¹uÏ£ÍuÄÚÈÝÒ»½øÈecache¾Í²»É¾³ý£¬Ö±µ½±»Ö÷¶¯purgeµoΪֹ£¬¿ÉÒÔ¼ÓÉÏignore-reloadÑ¡Ïi,Õa¸oÎÒÃdz£ÓÃÔÚmp3,wma,wmv,gifÖ®Àa¡£
Examples:
refresh_pattern -i \.mp3$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.wmv$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.rm$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.swf$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.mpeg$ 1440 50% 2880 ignore-reload
refresh_pattern -i \.wma$ 1440 50% 2880 ignore-reload
resource age =¶ÔÏo½øÈecacheµÄʱ¼a-¶ÔÏoµÄlast_modified
response age =µ±Ç°Ê±¼a-¶ÔÏo½øÈecacheµÄʱ¼a
LM-factor=(response age)/(resource age)
¾Ù¸oÀý×Ó,ÕaÀiÖ»¿¼ÂÇpercent, ²»¿¼ÂÇmin ºÍmax
ÀýÈ磺refresh_pattern 20%
¼ÙÉeÔ´*þÎñÆ÷ÉÏwww.aaa.com/index.htm -----lastmodified ÊÇ 2007-04-10 02:00:00
squidÉÏ proxy.aaa.com/index.htm index.htm½øÈecacheµÄʱ¼a 2007-04-10 03:00:00

1£(C)Èç¹uµ±Ç°Ê±¼a 2007-04-10 03:00:00
resource age =3µa-2µa=60ÖÖÓ
response age =0
ÖÖÓ
index.htm»¹¿ÉÒÔÔÚcacheÍ£ÁoµÄʱ¼a(resource age)20%=12ÖÖÓ
Ò²¾ÍÊÇ˵£¬index.htm½øÈecacheºo£¬¿ÉÒÔÍ£Áo12ÖÖÓ£¬²Å±»ÖØÐÂÈÈÏ¡£

2£(C)Èç¹uµ±Ç°Ê±¼a 2007-04-10 03:05:00
resource age =3µa-2µa=60ÖÖÓ
response age =5
ÖÖÓ
index.htm»¹¿ÉÒÔÔÚcacheÍ£ÁoµÄʱ¼a(resource age)20%=12ÖÖÓ-5=7
LM-factor=5/60=8.3%<20%

Ò»Ö±µ½2007-04-10 03:12:00 LM-factor=12/60=20% Ö®ºo£¬cacheÖеÄÒ³Ãaeindex.htmÖÕÓÚstale¡£
Èç¹uÕaʱûÓÐindex.htmµÄÇeÇo£¬index.htm»aÒ»Ö±ÔÚ»º´aeÖУ¬Èç¹uÓÐindex.htmÇeÇo£¬squidÊÕµ½¸ÃÇeÇoºo£¬ÓÉÓÚÒѾ­¹ýÆÚ£¬ squid»aÏoÔ´þÎñÆ÷¢Ò»¸oindex.htmÊÇñÓиıaµÄÇeÇo£¬Ô´þÎñÆ÷ÊÕµ½ºo£¬Èç¹uindex.htmûÓиuУ¬squid¾Í²»Óøuлº´ae£¬Ö±½Ó°Ñ»º´aeµÄÄÚÈÝŻظø¿Í»§¶Ë£¬Í¬Ê±£¬ÖØÖöÔÏo½øÈecacheµÄʱ¼aΪÓeÔ´þÎñÆ÷ÈÈϵÄʱ¼a£¬±ÈÈç2007-04-10 03:13:00£¬Èç¹uÕýºÃÔÚÕa¸oºoÖØÐÂÈÈÏÁËÒ³Ãae¡£ÖØÖúo£¬resource age±a³¤£¬ÏaÓ¦ÔÚcacheÖдae»iµÄʱ¼aÒ²±a³¤¡£

Èç¹uÓиıaÔo°Ñ×iеÄindex.htmµ»Ø¸øsquid,squidÊÕµ½»a¸uлº´ae£¬È»ºo°ÑеÄindex.htmµ»Ø¸ø¿Í»§¶Ë,ͬʱ¸u¾ÝÐÂÒ³ÃaeÖеÄLast_ModifiedºÍÈ¡Ò³ÃaeµÄʱ¼a£¬ÖØмÆËaresource age£¬½øÒ»²½¼ÆËa³o´ae»iʱ¼a¡£

ʵ¼ÊÉÏ£¬Ò»¸oÒ³Ãae½øÈecacheºo£¬ËuµÄ´ae»iʱ¼a¾Íȶ¨ÁË£¬¼´ (resource age) °Ùֱȣ¬Ò»Ö±µ½±»ÖØÐÂÈÈÏ¡£

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
文件下载
贪吃蛇
双位运算符
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
发送邮件
年的日历图
提取后缀名
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例