There is no way to clear the folder contents. You can only clear the specified link cache
Copy code The code is as follows:
function clearVarnish($ip,$url,$host=null){
$errstr = '';
$errno = '';
$varnist_arr = isset($host) ? $ host : C('VARNISH_LIST');
foreach ($varnist_arr as $v){
$fp = fsockopen ($ip, 2000, $errno, $errstr, 2);
if (!$ fp) {
return false; s( $fp , 4096);
fclose ($fp);
return $out;
}
}
}
?>
It should be noted that:
The incoming url cannot take parameters, such as: www.baidu.com/?tn=sougou
Because purge.url is cleared after regular rules The expression can be changed to www.baidu.com/(.?)sougou and that's it. When a varnish caches the content of multiple sites and needs to clear the specified site URL or simply clear the site homepage, purge must be used instead of purge.urlCopy code
The code is as follows:function varnish_purge($ip, $host='', $url) { $errstr = '';
$errno = '';
$fp = fsockopen ($ip, 2000, $errno, $errstr, 2);
if (!$fp) {
return $errno;
}else {
if( !empty($host)){
$out = "purge req.http.host == {$host} && req.url ~ ^/$ rn";
" purge.url {$url} rn";
close ($fp);
return $out;
http://www.bkjia.com/PHPjc/327716.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/327716.html
TechArticle
Unable to clear the folder contents, you can only clear the specified link cache. Copy the code as follows: ?php function clearVarnish($ip ,$url,$host=null){ $errstr = ''; $errno = ''; $varnist_arr = isse...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn