Question about purge_url & purge_hash

Phuwadon Danrahan Phuwadon at sanookonline.co.th
Mon Jul 28 12:28:48 CEST 2008


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.



More information about the varnish-misc mailing list