Permalink
Browse files

Merge remote-tracking branch 'upstream/master'

  • Loading branch information...
brookinsconsulting committed Feb 7, 2019
2 parents 98f5b01 + 592f726 commit 177f6c12522c998337a261445172cbbffc8d04d0
Showing with 16 additions and 10 deletions.
  1. +16 −10 doc/varnish/vcl/varnish4_xkey.vcl
@@ -132,9 +132,7 @@ sub ez_purge {

# Support how purging was done in earlier versions, this is deprecated and here just for BC for code still using it
if (req.method == "BAN") {
if (!client.ip ~ invalidators) {
return (synth(405, "Method not allowed"));
}
call ez_purge_acl;

if (req.http.X-Location-Id) {
ban("obj.http.X-Location-Id ~ " + req.http.X-Location-Id);
@@ -146,9 +144,7 @@ sub ez_purge {
}

if (req.method == "PURGE") {
if (!client.ip ~ invalidators) {
return (synth(405, "Method not allowed"));
}
call ez_purge_acl;

# If http header "key" is set, we assume purge is on key and you have Varnish xkey installed
if (req.http.key) {
@@ -164,6 +160,18 @@ sub ez_purge {
}
}

sub ez_purge_acl {
// if (req.http.x-purge-token) {
// # Won't work on Varnish <= 5.1, if needed in 4.1 you can hardcode a secret token here instead of std.getenv() usage
// if (req.http.x-purge-token != std.getenv("HTTPCACHE_VARNISH_INVALIDATE_TOKEN")) {
// return (synth(405, "Method not allowed"));
// }
// } else if (!client.ip ~ invalidators) {
if (!client.ip ~ invalidators) {
return (synth(405, "Method not allowed"));
}
}

// Sub-routine to get client user context hash, used to for being able to vary page cache on user rights.
sub ez_user_context_hash {

@@ -253,10 +261,8 @@ sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
set resp.http.X-Cache-Hits = obj.hits;
// Not readable on Varnish 4.1LTS, so check for existence until we drop support for it in future versions
if (obj.ttl) {
set resp.http.X-Cache-TTL = obj.ttl;
}
// For Varnihs 5.1+ you can uncomment this to get debug of remaining TTL
//set resp.http.X-Cache-TTL = obj.ttl;
} else {
set resp.http.X-Cache = "MISS";
}

0 comments on commit 177f6c1

Please sign in to comment.