Well, I'll keep it simple, PURGE requests (or so I thought?) were pretty much all handled by literally:
acl purge {
"localhost";
"127.0.0.1";
}
and then
if (req.method == "PURGE") {
if (!client.ip ~ purge) {
return(synth(405, "This IP is not allowed to send PURGE requests."));
}
return (purge);
}
I fairly certain both of the above statements are "correct", the thing I'm hung-up on is that if I sent a
curl -X PURGE http://domain.com/
or
curl -X PURGE http://domain.com/.*
and Varnish sends back 200 Purged well... the cache is purged? Even if it's just the homepage and not the entire cache (swear it was all using the above .* method) is and the above snippets of code are correct is there any particular reason http://domain.com (as in the actual homepage) isn't purged?
varnishncsa shows:
MYIP - - [16/Feb/2015:23:23:10 -0600] "PURGE http://domain.com/ HTTP/1.1" 200 241 "-" "curl/7.29.0"
I know I gotta be missing something silly but I can't figure it out?
The official documentation says basically what you've done, but keep in mind PURGE != BAN, you can use regular expressions in BAN, but not in PURGE. With PURGE you delete all the Vary defined copies of one particular url.
In my tests with 4.0.2 it works as advised, I have the homepage cached, I do a curl -X PURGE http://localhost:8080/
and in varnishlog I see (among other things):
* << Request >> 65542
- Begin req 65541 rxreq
- Timestamp Start: 1424188792.108573 0.000000 0.000000
- Timestamp Req: 1424188792.108573 0.000000 0.000000
- ReqStart ::1 60496
- ReqMethod PURGE
- ReqURL /
- VCL_acl MATCH purge "localhost"
- VCL_return purge
- VCL_call HASH
- VCL_return lookup
- VCL_call PURGE
And reloading I see a MISS & backend request (because it's not in the cache):
* << BeReq >> 65548
- Begin bereq 65547 fetch
- Timestamp Start: 1424188815.112540 0.000000 0.000000
- BereqMethod GET
- BereqURL /
- BereqProtocol HTTP/1.1
- VCL_call BACKEND_RESPONSE
- TTL VCL 120 21600 0 1424188815
- VCL_return deliver
* << Request >> 65547
- Begin req 65546 rxreq
- ReqMethod GET
- ReqURL /
- VCL_return hash
- VCL_call HASH
- VCL_return lookup
- Debug "XXXX MISS"
- VCL_call MISS
- VCL_return fetch
- Link bereq 65548 fetch
BTW Add "::1" to the list of ips in the purge acl just in case you are using ipv6. It would have returned a 405, but who knows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With