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.

These examples work to purge (first) a folder and the domain root

varnishadm -S /etc/varnish/secret -T localhost:6082 "ban req.http.host == mysite.com && req.url ~ ^/fold/.*$"
varnishadm -S /etc/varnish/secret -T localhost:6082 "ban req.http.host == mysite.com && req.url ~ ^/.*$"

How can I purge just one file " index2.html " (for example)

" ...&& req.url ~ ^/index2.html$"

The above gives no error message, but doesn't work.

Edit: Retesting showed I originally had a typo when trying to work w/ the single file. The format (posted here) does work.

share|improve this question
    
How exactly does it not work? Does the ban not show up in the ban list (ban.list I think, still on 2.1.x myself), or does it serve content that should be banned? If it's the latter, can you provide the output of ban.list, and the logging of a request that not lived up to your expectations? –  arjarj May 3 '12 at 7:31
    
I was thinking perhaps I formatted this part ( "... ^/index2.html$" ) 'slightly wrong.' (When "converting" from a directory to a single file) ... How exactly does it not work? == Served the stale content. ... I'll get back later for more testing, thank you. –  This_Is_Fun May 3 '12 at 7:55
    
What version of Varnish are you using? In 3.x, you typically purge a file by passing a PURGE request (e.g. using curl). Depending on your setup, you may also need to pass a PURGE request for a compressed version of the file. For example: curl -X PURGE --http1.0 --head --header "Host: example.com" 127.0.0.1/path/to/file.ext (--http1.0 can be omitted) and curl --compressed -X PURGE --http1.0 --head --header "Host: example.com" 127.0.0.1/path/to/file.ext. –  cyberx86 May 3 '12 at 19:51
    
varnish-3.0.2 / @cyberx86 Does 'remote' purge (using curl) need to be enabled in the vcl? As an ACL? –  This_Is_Fun May 4 '12 at 7:25
1  
@This_Is_Fun: you do need to modify your VCL for purging, and that usually includes setting up an ACL. See the differences between purges and bans, and the basic changes required for purges, in the documentation. –  cyberx86 May 4 '12 at 10:41

1 Answer 1

i have test the below ,it work fine for me. hope it helps.

/usr/local/bin/varnishadm "ban req.http.host == d.oozk.com && req.url ~ ^/wp-content/themes/twentyeleven/style.css"
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.