Question about purge_url & purge_hash

Phuwadon Danrahan Phuwadon at sanookonline.co.th
Mon Aug 4 11:43:53 CEST 2008


Hi all,

I just found the way to do purge_hash in vcl. Try it yourself, it
supports regular expression in both req.url & req.http.host.

VCL_RECV
         if (req.request == "PURGE") {
	if (client.ip ~ backoffice) {
		set req.http.x = req.url "#" req.http.host "#";
                	purge_hash(req.http.x);            
		error 200 "HASHPURGED";
	}
         }
                

-----Original Message-----
From: varnish-misc-bounces at projects.linpro.no
[mailto:varnish-misc-bounces at projects.linpro.no] On Behalf Of Phuwadon
Danrahan
Sent: Monday, July 28, 2008 5:29 PM
To: varnish-misc at projects.linpro.no
Subject: Question about purge_url & purge_hash

Hi all,

I configured the Varnish 1.1.2-r2635 to allow purging from backoffice
web servers. The first version of this concept is very easy, just send
PURGE request for specific URL to Varnish servers.

Configuraiton,

VCL_RECV
         if (req.request == "PURGE") {
	if (client.ip ~ backoffice) {
                  lookup;
            }
         }

VCL_HIT
        if (req.request == "PURGE") {
                set obj.ttl = 0s;
                error 200 "Purged";
        }
	
This above configuration is working fine but the application owner would
like to purge some URL that contains multiple paging in only one PURGE
request. The example is

http://myhost.com/path/to/index.php?id=123&page=1
http://myhost.com/path/to/index.php?id=123&page=2
http://myhost.com/path/to/index.php?id=123&page=3

Sometimes, the maximum page can be more than 1000. So, we think about
purge_url(req.http) but it always return MISS when we input the URL with
REGEX. 

What did we test the VCL configuration
1. use WFETCH to get content from varnish with the following request
headers,
	GET /path/to/file.gif HTTP/1.0\r\n
	Host: myhost.com\r\n
	Accept-Encoding: gzip\r\n
2. use WFETCH to purge content from varnish with the following request
headers,
	PURGE /path/to/file.gif HTTP/1.0\r\n
	Host: myhost.com\r\n
	Accept-Encoding: gzip\r\n

  We can purged the object in this step

3. We tried,
	PURGE \.gif$ HTTP/1.0\r\n
	Host: myhost.com\r\n
	Accept-Encoding: gzip\r\n
  But this one can not be purged which we require this kind of purging
style (allow REGEX)

Could anyone provide the valid use of purge_url or purge_hash in both
vcl_recv and vcl_hit? and how can we input the REGEX url into purging
request? 

Thank you.
Phuwadon D.
_______________________________________________
varnish-misc mailing list
varnish-misc at projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc



More information about the varnish-misc mailing list