RE: Question about purge_url & purge_hash

2008-08-04 Thread Phuwadon Danrahan
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: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Phuwadon
Danrahan
Sent: Monday, July 28, 2008 5:29 PM
To: varnish-misc@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@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Question about purge_url & purge_hash

2008-07-28 Thread Phuwadon Danrahan
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@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: purge_url

2008-01-08 Thread Dag-Erling Smørgrav
Erik <[EMAIL PROTECTED]> writes:
> [redacted]
>
> sub vcl_recv {
> if (req.http.host == "10.1.1.54" || req.http.host == 
> "test.mysite.com") {
> set req.http.host = "www.mysite.com";
> }
>
> if (req.request == "PURGE") {
> if (client.ip ~ purge) {
> purge_url(req.url);
> }
> }
> }
>
> sub vcl_miss {
> if (req.request == "PURGE") {
> error 404 "The url could not be found in the cache.";
> }
> }
>
> sub vcl_hit {
> if (req.request == "PURGE") {
> set obj.ttl = 0s;
> error 200 "Purged successfully!";
> }
> }

You are mixing two different purge mechanisms.  I think what you want
is listed in the EXAMPLES section in the vcl(7) manual page.

Also, the PURGE request you showed did not include a Host: header at
all, so your host normalization code never kicked in, and you tried to
purge a different document from the one you later requested.

DES
-- 
Dag-Erling Smørgrav
Senior Software Developer
Linpro AS - www.linpro.no
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: purge_url

2007-12-17 Thread Anders Nordby
On Thu, Dec 13, 2007 at 12:02:38PM +0100, Erik wrote:
> I will stop bothering the helpful guys at the irc for a minute and ask a 
> question here ;) 
> 
> My VCL conf looks like this:
> sub vcl_recv {
> #Change the host header to www.mysite.com
> if(req.http.host == "10.1.1.54" || req.http.host == 
> "test.mysite.com") {
> set req.http.host = "www.mysite.com";
> }
> 
> #Purge specified files from acl purge.
> #Purge = Delete the specified url from the cache
> if(req.request == "PURGE") {
> if(client.ip ~ purge) {
> purge_url(req.url);
> }
> }

I would change this part to:

if(req.request == "REPURGE") {
if(client.ip ~ purge) {
purge_url(req.url);
error 200 "Repurged."
}
}

If you are sending a regexp purge, you will always get a miss, unless
you accidentally don't use any regexp special characters - which does
not make sence. In any case, I recommend using a different request for
normal purge and regexp purge, but supporting both in the VCL.

Bye,

-- 
Anders.
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


purge_url

2007-12-13 Thread Erik
I will stop bothering the helpful guys at the irc for a minute and ask a 
question here ;) 

My VCL conf looks like this:
sub vcl_recv {
#Change the host header to www.mysite.com
if(req.http.host == "10.1.1.54" || req.http.host == "test.mysite.com") {
set req.http.host = "www.mysite.com";
}

#Purge specified files from acl purge.
#Purge = Delete the specified url from the cache
if(req.request == "PURGE") {
if(client.ip ~ purge) {
purge_url(req.url);
}
}

sub vcl_miss {
#set http version 1.1
set bereq.proto = "HTTP/1.1";

if (req.request == "PURGE") {
error 404 "The url could not be found in the cache.";
}
}

sub vcl_hit {
if (req.request == "PURGE") {
set obj.ttl = 0s;
error 200 "Purged successfully!";
}
}

}
# End of VCL Conf

I receive a 404 error "The url could not be found in the cache." when I try to 
PURGE the url.
PURGE http://www.mysite.com/data/hello.gif HTTP/1.1

This is the varnishlog when I try to purge:

  12 RxRequestc PURGE
   12 RxURLc /data/hello.gif
   12 RxProtocol   c HTTP/1.1
   12 VCL_call c recv
   12 VCL_acl  c MATCH purge "84.xx.xx.xx"
   12 VCL_return   c lookup
   12 VCL_call c hash
   12 VCL_return   c hash
   12 Debugc "Hash: /data/hello.gif#10.1.1.54:80#"
   12 VCL_call c miss
0 Debug  "VCL_error(404, The url could not be found in the cache.)"
   12 VCL_return   c error
   12 Length   c 453
   12 TxProtocol   c HTTP/1.0
   12 TxStatus c 404
   12 TxResponse   c Not Found
   12 TxHeader c Server: Varnish
   12 TxHeader c Retry-After: 0
   12 TxHeader c Content-Type: text/html; charset=utf-8
   12 TxHeader c Content-Length: 453
   12 TxHeader c Date: Thu, 13 Dec 2007 11:34:50 GMT
   12 TxHeader c X-Varnish: 1188471893
   12 TxHeader c Age: nan
   12 TxHeader c Via: 1.1 varnish
   12 TxHeader c Connection: keep-alive

When I try to request it with GET i receive:

  12 ReqStart c 84.xx.xx.xx 32162 1188471894
   12 RxRequestc GET
   12 RxURLc /data/hello.gif
   12 RxProtocol   c HTTP/1.1
   12 RxHeader c Host: www.mysite.com
   12 RxHeader c User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; 
sv-SE; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
   12 RxHeader c Accept: 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
   12 RxHeader c Accept-Language: sv,en-us;q=0.7,en;q=0.3
   12 RxHeader c Accept-Encoding: gzip,deflate
   12 RxHeader c Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
   12 RxHeader c Keep-Alive: 300
   12 RxHeader c Connection: keep-alive
   12 RxHeader c 
Cookie:__utma=75765975.864378540.1197378455.1197453843.1197535348.6; 
   12 VCL_call c recv
   12 VCL_return   c lookup
   12 VCL_call c hash
   12 VCL_return   c hash
   12 Debugc "Hash Match: /data/hello.gif#www.mysite.com#"
   12 Hit  c 1188471893
   12 VCL_call c hit
   12 VCL_return   c deliver
   12 Length   c 905
   12 VCL_call c deliver
   12 VCL_return   c deliver
   12 TxProtocol   c HTTP/1.1
   12 TxStatus c 200
   12 TxResponse   c OK
   12 TxHeader c Server: Zeus/4.3
   12 TxHeader c Content-Type: image/gif
   12 TxHeader c Content-Language: sv-SE
   12 TxHeader c Content-Length: 905
   12 TxHeader c Date: Thu, 13 Dec 2007 11:37:26 GMT
   12 TxHeader c X-Varnish: 1188471894 1188471893
   12 TxHeader c Age: 43
   12 TxHeader c Via: 1.1 varnish
   12 TxHeader c Connection: keep-alive

The strange thing is that the host is different in PURGE Match and GET Match. I 
have used the same host on both requests. Does it have anything to do with the 
vcl code where Im changing the hostheader?

/ Erik

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc