Hello,
VCL provided for Varnish 4 includes commented lines about purge. I tried to use the code included for purge method, but it does not work.
My varnishadm does not work as expected and Drupal Varnish module cannot exec ban command. I try to figure how to use Drupal Purge module to avoid Varnish Administration
I tried return purge as usual, and later i tried return hash (as provided at example).
My default.vcl has:
acl purge {
"localhost";
"127.0.0.1";
}
// TODO: Add purge handler, access checks and other stuff relying on
// non-standard HTTP verbs here.
// /**
// * Example 1: Allow purge from all clients in the purge-acl. Note that
// * additional VCL is necessary to make this work, notably the acl and some
// * code in vcl_backend_fetch and vcl_hit.
// *
// * More information on:
// * https://www.varnish-cache.org/docs/3.0/tutorial/purging.html
// */
// if (req.method == "PURGE") {
// if (!client.ip ~ purge) {
// return (synth(405));
// }
// return (hash);
// }
# Check the incoming request type is "PURGE", not "GET" or "POST".
if (req.method == "PURGE") {
# Check if the IP is allowed.
if (!client.ip ~ purge) {
# Return error code 405 (Forbidden) when not.
return (synth(405, "Not allowed:"));
}
return (hash);
// This return is the standard return, but it is not used at provided example
# return (purge);
}
I did not found any other comment about purge, also i was googling for some days, but all the standar methods does not work for me.
I think the clue would be this part of comment:
and some code in vcl_backend_fetch and vcl_hit.
Have anybody experience with purge method and Authcache vcl?
Can you give me any suggestion about the code should i write in vcl_backend_fetch or vcl_hit?
Also i added a condition to allow me see fresh content with CTRL + F5:
if (req.http.cache-control == "no-cache")
{
# return (pass);
return (hash);
}
I changed return pass for return hash to follow the tip above, and i can get a fresh page content the first load, but sucesive reloads with F5 continues returning the old cached content.
I think i can became rewriting vcl and continue investigating if anybody can suggest me how to force Varnish to rebuild the cache for a URL, based on Authcache vcl.
Any suggestion will be appreciated.
Thanks.
Jose
Comments
Comment #2
znerol CreditAttribution: znerol commentedSee purge docs for Varnish 4.0.
Comment #3
znerol CreditAttribution: znerol commentedThis changed from Varnish 3 to Varnish 4. They introduced a new purge action. Use
return(purge)
instead ofreturn(hash)
invcl_recv
, that in turn eliminates the need to add the snippets tovcl_miss
andvcl_hit
.Patch for docs changes attached.
Comment #5
Holoduke CreditAttribution: Holoduke commentedThanks for fast reply.
return (purge) solved the problem.
There are more advanced examples at Varnish Book, I hope this helps other users:
Varnish Book: Cache Invalidation
Comment #7
znerol CreditAttribution: znerol commentedThanks for taking the time to report this issue.