Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Varnish is being used in a Wordpress website.

I would like to purge Varnish for a single URL instead of a whole domain.

With this command I can restart Varnish for the whole domain:

varnishadm -T :6082 -S /etc/varnish/secret 'ban req.http.host ~ \"http://www.foo.com\" && req.url ~ \"^/\"'

However I would like to purge varnish only for a single url.

Ex: www.foo.com/url_to_be_purged

I've tried the previous command replacing it with the single URL:

varnishadm -T :6082 -S /etc/varnish/secret 'ban req.http.host ~ \"http://www.foo.com/url_to_be_purged\" && req.url ~ \"^/\"'

But it didn't work, the URL still was a HIT in Varnish.

Any ideas of how can I achieve this?

UPDATE

As suggested ghloogh's answer, I've tried the following command:

varnishadm -T :6082 -S /etc/varnish/secret ban "req.http.host == http://www.foo.com && req.url == http://www.foo.com/url_to_be_purged"

I've also tried this variation:

varnishadm -T :6082 -S /etc/varnish/secret ban "req.http.host == http://www.foo.com && req.url == /url_to_be_purged"

But I still get a HIT in the URL and the data is not updated

share|improve this question
    
man, stop using scheme (http:// or https:// or ftp:// or other) in hostname :) your command should be: varnishadm -T :6082 -S /etc/varnish/secret ban "req.http.host == www.foo.com && req.url == /url_to_be_purged" –  ghloogh Jul 11 '13 at 15:42

1 Answer 1

You don't need to specify scheme for hostname and you may use strict match instead of regex:

varnishadm -T 127.0.0.1:6082 -S /etc/varnish/secret ban "req.http.host == example.com && req.url == /some/url/"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.