[Varnish] #1808: Error in Varnish Request Flox
Varnish
varnish-bugs at varnish-cache.org
Thu Oct 22 17:24:35 CEST 2015
#1808: Error in Varnish Request Flox
-----------------------------+--------------------
Reporter: colas | Type: defect
Status: new | Priority: high
Milestone: Varnish 4.0-TP2 | Component: build
Version: trunk | Severity: normal
Keywords: |
-----------------------------+--------------------
Hello,
We use varnish-4.0.3 revision b8c4a34.
I think there are an error with the Varnish request Flow.
There a part of my conf
{{{
vcl 4.0;
import directors;
import std;
include "/etc/varnish/cfdoc.vcl";
include "/etc/varnish/devicedetect.vcl";
sub vcl_init {
new xxx = directors.round_robin();
xxx.add_backend(xxx1);
}
acl acl_reseaudoc {
...
"127.0.0.1";
}
sub vcl_recv {
call devicedetect; #On identifie les devices mobiles ou non
(include devicedetect.vcl)
if( client.ip ~ acl_reseaudoc) { # Force lookup if request is a
no-cache request from client
if (req.http.Pragma ~ "no-cache" && req.http.Cache-Control
~ "no-cache") {
if (req.method == "GET" ) { # On ne purge que sur
un GET, jamais sur un POST
ban("req.url == "+req.url); # Send the
"purge" command to the purge queue in a REGEXP form
return (synth(202, "Confirmation de purge
de la page"));
}
}
}
set req.backend_hint = xxx.backend(); # send all traffic to the
vdir director
set req.http.Via = "1.1 varnish-v4";
set req.http.grace = "none";
if (req.restarts == 0) {
if (req.http.X-Forwarded-For) { # set or append the
client.ip to X-Forwarded-For header
set req.http.X-Forwarded-For = req.http.X
-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
#For debug
set req.http.X-Pass = "Debug-Pass";
return(pass);
....
return(hash);
}
# Called after vcl_recv to create a hash value for the request.
# This is used as a key to look up the object in Varnish.
sub vcl_hash {
set req.http.X-Pass = req.http.X-Pass+" hash";
hash_data(req.url);
if (req.http.host) {
hash_data(req.http.host);
} else {
hash_data(server.ip);
}
# On cache spécifiquement par type de device client
if (!req.url ~
"^[^?]*\.(bmp|bz2|js|doc|eot|flv|gif|tgz|gz|ico|jpeg|jpg|less|pdf|png|rtf|swf|txt|woff|xml|mp3|mp4)(\?.*)?$")
{
if (req.http.X-UA-Device ~ "mobile") {
hash_data("mobile");
}
}
}
sub vcl_hit {
set req.http.X-Pass = req.http.X-Pass+" hit";
# Called when a cache lookup is successful.
if (obj.ttl >= 0s) { # normal hit
return (deliver);
}
# We have no fresh fish. Lets look at the stale ones.
if (std.healthy(req.backend_hint)) {
# Backend is healthy. Limit age to 10s.
if (obj.ttl + 10s > 0s) {
set req.http.grace = "normal(limited)";
return (deliver);
} else {
# No candidate for grace. Fetch a fresh object.
return(fetch);
}
} else {
# backend is sick - use full grace
if (obj.ttl + obj.grace > 0s) {
# Object is in grace, deliver it
# Automatically triggers a background fetch
set req.http.grace = "full";
return (deliver);
} else {
# no graced object.
return (fetch);
}
}
}
sub vcl_miss {
set req.http.X-Pass = req.http.X-Pass+" miss";
return(fetch);
}
sub vcl_pass {
set req.http.X-Pass = req.http.X-Pass+" pass";
}
sub vcl_backend_fetch {
}}}
When I request a page I get this header :
X-Pass:Debug-Pass hash Pass
But if I read the documentation https://www.varnish-
software.com/book/4.0/chapters/VCL_Basics.html#detailed-varnish-request-
flow-for-the-client-worker-thread
If I make a return(pass) from vcl_recv I must bypass vcl_hash. With my
debug it's not the case.
I have :
vcl_recv => vcl_hash => vcl_pass
thank
--
Ticket URL: <https://www.varnish-cache.org/trac/ticket/1808>
Varnish <https://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list