Any option to identify if a request is pass in browser headers.
Nicolas Delmas
colas.delmas at gmail.com
Thu May 18 12:00:28 CEST 2017
Hi,
Yes it's possible. I did something similar on my configuration :
I use the header req.http.X-Pass to set the reason why I get a MISS / PASS
:
*Exemple*
sub vcl_recv {
if (req.url ~ "\?s="
|| req.url ~ "/feed"
|| req.url ~ "/mu-.*"
|| req.url ~ "/wp-(login|admin)"
|| req.url ~ "/(cart|my-account|checkout|addons|/?add-to-cart=)") {
set req.http.X-Pass = "Wordpress Urls";
return (pass);
}
}
In the subroutine MISS, used when your object is not in cache I had the
header too.
sub vcl_miss {
set req.http.X-Pass = "Not-in-cache";
return (fetch);
}
I change the condition in the vcl_deliver to display the reason of the MISS
(and you could differenciate if it was a real MISS or if it was a PASS),
and use this condition (*obj.uncacheable*) that allow me to know if the
object has mark as Hit-For-Pass
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
} else if (obj.uncacheable && req.http.X-Pass ~ "Not-in-Cache") {
set resp.http.X-Cache = "MISS : Hit-For-Pass";
} else {
set resp.http.X-Cache = "MISS : " + req.http.X-Pass;
}
}
So you could had a header in the vcl_pass and test it in order you display
PASS instead of MISS in the vcl_deliver
Nicolas
*Nicolas Delmas*
http://tutoandco.colas-delmas.fr/ <colas.delmas at gmail.com>
2017-05-18 8:56 GMT+02:00 sreeranj s <sreeranj4droid at gmail.com>:
> Hi All,
>
>
> Following is added in vcl-deliver section to identify if the content is
> served from cache or from backend. Similarly is there an option that we can
> identify if the request was a PASS
>
> ==========================================
>
> sub vcl_deliver {
>
> # Sometimes it's nice to see when content has been served from the cache.
> if (obj.hits > 0) {
> # If the object came from the cache, set an HTTP header to say so
> set resp.http.X-Cache = "HIT";
> } else {
> set resp.http.X-Cache = "MISS";
> }
>
> # For security and asthetic reasons, remove some HTTP headers before final delivery...
> remove resp.http.Server;
> remove resp.http.X-Powered-By;
> remove resp.http.Via;
> remove resp.http.X-Varnish;}
>
>
>
> ==========================================
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20170518/9833e256/attachment.html>
More information about the varnish-misc
mailing list