help me , Solve the problem about purge cache

Ajian ajian521 at gmail.com
Fri Feb 27 18:41:21 CET 2009


      This is not the varnish bug. But I don't know how to solve it ,and the
document is few.Please help me .Thanks.
     The problem is about how to purge the cache by the http.
     When my hash is the fellow ,I can solve it

    sub vcl_hash {
    set req.hash += req.url;
    hash;
}

    I have write a php file to purge the cache

   <?php
        function purge($ip, $domain, $url)
        {
        $errstr = '';
        $errno = '';
        $fp = fsockopen ($ip, 80, $errno, $errstr, 2);
        if (!$fp)
        {
        return false;
        }
        else
        {
        $out = "PURGE $url HTTP/1.1\r\n";
        $out .= "Host:$domain\r\n";
        $out .= "Connection: close\r\n\r\n";
        fputs ($fp, $out);
        $out = fgets($fp , 4096);
        echo $out;
        fclose ($fp);
        return true;
        }
        }

        $domain = $_GET['a'];
        $imgurl = $_GET['b'];

        $squid = array(
        '221.238.196.199',
        '221.238.196.200',
        );

        foreach($squid as $ip)
        {
        if(!empty($ip))
        {
        purge($ip, $domain, $imgurl);
        echo "clear is over";
        }
        }

  ?>

But, I change the hash, use the similar way but can't clear it ,output
"tHTTP/1.1 404 Not in cache "

sub vcl_hash {
    set req.hash += req.url;
   if (req.http.host) {
        set req.hash += req.http.host;
    } else {
        set req.hash += server.ip;
    }
    if (req.http.Accept-Encoding) {
        set req.hash += req.http.Accept-Encoding;
    }
    hash;
}

who can tell me how to purge the hash cache ,how to write the php ,I need
through remote empty cache ,thanks.

I hope you can understand what I mean, my English is pool.


Ajian

   I
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-bugs/attachments/20090228/bee13ba9/attachment.html>


More information about the varnish-bugs mailing list