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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Holoduke created an issue. See original summary.

znerol’s picture

znerol’s picture

This changed from Varnish 3 to Varnish 4. They introduced a new purge action. Use return(purge) instead of return(hash) in vcl_recv, that in turn eliminates the need to add the snippets to vcl_miss and vcl_hit.

Patch for docs changes attached.

Status: Needs review » Needs work

The last submitted patch, 3: 2806137-varnish-4-purge-docs.diff, failed testing.

Holoduke’s picture

Thanks 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

  • znerol committed 01dd2a8 on 7.x-2.x
    Issue #2806137 by znerol: Varnish 4 purge
    
znerol’s picture

Status: Needs work » Fixed

Thanks for taking the time to report this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.