Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Varnish 3 varnishadm #27

Merged
merged 1 commit into from May 29, 2012
Merged

Varnish 3 varnishadm #27

merged 1 commit into from May 29, 2012

Conversation

snow0x2d0
Copy link

Looks like there may have been a typo in the section for varnish 3 and using varnish adm. The line was using 'ban req.http.url' instead of 'req.url'.

pkhamre added a commit that referenced this pull request May 29, 2012
@pkhamre pkhamre merged commit 61164ef into pkhamre:master May 29, 2012
@linickx
Copy link
Contributor

linickx commented May 29, 2012

Hello,

The syntax came from.... https://www.varnish-cache.org/docs/3.0/tutorial/purging.html, the example given in the tutorial is:

ban req.http.host == "example.com" && req.http.url ~ "\.png$"

as it happens, both commands appear to work...

[nick@server ~]$ rpm -qa | grep varnish
varnish-release-3.0-1
varnish-3.0.2-1.el5
varnish-libs-3.0.2-1.el5
[nick@server ~]$ 
[nick@server ~]$ sudo varnishadm 
200        
-----------------------------
Varnish Cache CLI 1.0
-----------------------------
Linux,2.6.35.4-rscloud,x86_64,-sfile,-smalloc,-hcritbit

Type 'help' for command list.
Type 'quit' to close CLI session.

varnish> ban req.http.url ~ /robots.txt && req.http.host == www.linickx.com
200        

varnish> ban req.url ~ /robots.txt && req.http.host == www.linickx.com
200        

varnish>
varnish> quit
500        
Closing CLI connection
[nick@server ~]$

Kind Regards,
Nick

@snow0x2d0
Copy link
Author

Greetings,

I perhaps was incorrect in describing it as a typo (I was unaware of the req.http.url syntax). After a bit more research it does seem that req.url and req.http.url are intended to be synonymous. In practice however it does not appear that req.http.url behaves as expected when provided as a parameter to the 'ban' method via the varnishadm utility. When this patch was submitted it was after the method did not appear to clear the cache despite varnishadm returning a 200. I have verified this again with a fresh install of varnish 3.0.2:

Varnish configured on 6081 with localhost 80 as the backend, with the object already in the cache:

snowman@snowman-VirtualBox:~$ wget localhost:6081 -O /dev/null -S
--snip--
Date: Wed, 30 May 2012 02:24:33 GMT
X-Varnish: 879903476 879903472
Age: 8
Via: 1.1 varnish
Connection: close

While the ban is accepted using the req.http.url field name:
varnish> ban req.http.url ~ "^/$"
200

It does not appear to actually purge:

snowman@snowman-VirtualBox:~$ wget localhost:6081 -O /dev/null -S
--snip--
Date: Wed, 30 May 2012 02:24:38 GMT
X-Varnish: 879903477 879903472
Age: 13
Via: 1.1 varnish
Connection: close

However when cached again:

snowman@snowman-VirtualBox:~$ wget localhost:6081 -O /dev/null -S
--snip--
Date: Wed, 30 May 2012 02:27:52 GMT
X-Varnish: 879903480 879903478
Age: 4
Via: 1.1 varnish

And purged using req.url:

varnish> ban req.url ~ "^/$"
200

snowman@snowman-VirtualBox:~$ wget localhost:6081 -O /dev/null -S
--snip--
Date: Wed, 30 May 2012 02:28:13 GMT
X-Varnish: 879903481
Age: 0
Via: 1.1 varnish

So while the documentation shows it and varnishadm allows it, req.http.url does not seem to result in a ban or removal from the cache. There could be something I'm missing of course so if there's something I've overlooked please let me know as I'd rather not have a broken patch with name on it :D

@linickx
Copy link
Contributor

linickx commented May 30, 2012

Good Morning,

Nice work! I have runs some tests with curl ( to rule out any wget funnies) and I can confirm the same symptoms.

[nick@server ~]$ curl -I http://www.linickx.com/robots.txt
HTTP/1.1 200 OK
Last-Modified: Wed, 16 Feb 2011 13:18:03 GMT
Cache-Control: max-age=86400
Expires: Thu, 31 May 2012 07:59:11 GMT
Vary: Accept-Encoding,User-Agent
Content-Type: text/plain; charset=UTF-8
Date: Wed, 30 May 2012 08:28:40 GMT
X-Varnish: 632459904 632459710
Age: 1769
Via: 1.1 varnish
Connection: close
X-Cache: cached

[nick@server ~]$
[nick@server ~]$ sudo varnishadm
200        
-----------------------------
Varnish Cache CLI 1.0
-----------------------------
Linux,2.6.35.4-rscloud,x86_64,-sfile,-smalloc,-hcritbit

Type 'help' for command list.
Type 'quit' to close CLI session.

varnish> ban req.http.url ~ /robots.txt && req.http.host == www.linickx.com
200        

varnish> 
varnish> ban req.http.url ~ /robots.txt && req.http.host == www.linickx.com
200        

varnish> quit
500        
Closing CLI connection
[nick@server ~]$
[nick@server ~]$ curl -I http://www.linickx.com/robots.txt
HTTP/1.1 200 OK
Last-Modified: Wed, 16 Feb 2011 13:18:03 GMT
Cache-Control: max-age=86400
Expires: Thu, 31 May 2012 07:58:50 GMT
Vary: Accept-Encoding,User-Agent
Content-Type: text/plain; charset=UTF-8
Date: Wed, 30 May 2012 08:28:47 GMT
X-Varnish: 1222087994 1222087837
Age: 1797
Via: 1.1 varnish
Connection: close
X-Cache: cached

[nick@server ~]$
[nick@server ~]$ sudo varnishadm
200        
-----------------------------
Varnish Cache CLI 1.0
-----------------------------
Linux,2.6.35.4-rscloud,x86_64,-sfile,-smalloc,-hcritbit

Type 'help' for command list.
Type 'quit' to close CLI session.

varnish> ban req.url ~ /robots.txt && req.http.host == www.linickx.com
200        

varnish>varnish> quit
500        
Closing CLI connection
[nick@server ~]$
[nick@server ~]$ curl -I http://www.linickx.com/robots.txt
HTTP/1.1 200 OK
Last-Modified: Wed, 16 Feb 2011 13:18:03 GMT
Cache-Control: max-age=86400
Expires: Thu, 31 May 2012 08:32:50 GMT
Vary: Accept-Encoding,User-Agent
Content-Type: text/plain; charset=UTF-8
Date: Wed, 30 May 2012 08:32:50 GMT
X-Varnish: 1222088005
Age: 0
Via: 1.1 varnish
Connection: close
x-Cache: uncached

[nick@server ~]$

At this stage, I'm guessing you have have found a varnish bug :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants