<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hi Guillaume,</p>
<p>Thanks for your response. <br>
</p>
<p>I did some more testing and it seems the pages are somehow
getting cached irrespective of whatever logic I have put in the
vcl_backend_response:<br>
</p>
<p>sub vcl_backend_response { <br>
# Happens after we have read the response headers from the
backend. <br>
# <br>
# Here you clean the response headers, removing silly
Set-Cookie headers <br>
# and other mistakes your backend does. <br>
if (bereq.method == "GET") { <br>
set beresp.do_esi = true; <br>
if ((beresp.http.Set-Cookie !~ "loggedin_user=")
&& <br>
(beresp.http.Set-Cookie !~ "sessionid=")
&& <br>
(bereq.http.Cookie !~ "sessionid=") && <br>
(bereq.http.Cookie !~ "loggedin_user=") &&
<br>
(bereq.url !~ "^/esi")) { <br>
#unset beresp.http.Set-Cookie; <br>
set beresp.uncacheable = false; <br>
return(deliver); <br>
} <br>
} <br>
} </p>
Regarding the faulty request, Following are two requests for the
same URL - /heels/ - one when the user was logged in and another
when the user had logged out. The second one (when the user was
logged out) is the faulty one as the user is still seeing the data
when he was logged in.<br>
<br>
<b><u>For the logged in User:</u></b><br>
<br>
* << BeReq >> 65542 <br>
- Begin bereq 65541 pass<br>
- Timestamp Start: 1464273298.494530 0.000000 0.000000<br>
- BereqMethod GET<br>
- BereqURL /heels/<br>
- BereqProtocol HTTP/1.0<br>
- BereqHeader X-CLIENT-COUNTRY: IN<br>
- BereqHeader Host: varnish_staging<br>
- BereqHeader Cache-Control: max-age=0<br>
- BereqHeader Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8<br>
- BereqHeader Upgrade-Insecure-Requests: 1<br>
- BereqHeader User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS
X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/50.0.2661.102 Safari/537.36<br>
- BereqHeader Referer: <a class="moz-txt-link-freetext" href="http://test.jivaana.in/juttis/">http://test.jivaana.in/juttis/</a><br>
- BereqHeader Accept-Encoding: gzip, deflate, sdch<br>
- BereqHeader Accept-Language: en-US,en;q=0.8<br>
- BereqHeader Cookie:
_xsrf=2|f25d8caf|ffacf1c86b71827915f94aed8e9aeace|1462920275;
jivaana_country=IN; pagemap=0,0,0,0,0,1,0';
mp_774636c1ed2371eaf99455f71871069c_mixpanel=%7B%22distinct_id%22%3A%20%221518b8ba6c314b-04bd3d4-6b1b237b-100200-1518b8ba6c428a%22%2C%22%24i<br>
- BereqHeader X-Forwarded-For: 127.0.0.1<br>
- BereqHeader X-Varnish: 65542<br>
- VCL_call BACKEND_FETCH<br>
- VCL_return fetch<br>
- BackendOpen 21 boot.uwsgi 127.0.0.1 7090 127.0.0.1 57783<br>
- Timestamp Bereq: 1464273298.494747 0.000217 0.000217<br>
- Timestamp Beresp: 1464273298.507940 0.013410 0.013193<br>
- BerespProtocol HTTP/1.0<br>
- BerespStatus 200<br>
- BerespReason OK<br>
- BerespHeader Content-Length: 257701<br>
- BerespHeader Expires: Thu, 26 May 2016 14:39:55 GMT<br>
- BerespHeader Vary: X-CLIENT-COUNTRY, Cookie<br>
- BerespHeader X-CLIENT-COUNTRY: IN<br>
- BerespHeader Last-Modified: Thu, 26 May 2016 14:34:55 GMT<br>
- BerespHeader Cache-Control: max-age=300<br>
- BerespHeader Date: Thu, 26 May 2016 14:34:58 GMT<br>
- BerespHeader X-Frame-Options: SAMEORIGIN<br>
- BerespHeader Content-Type: text/html; charset=utf-8<br>
- BerespHeader Set-Cookie: jivaana_num_basket_items=;
expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/<br>
- TTL RFC 300 10 -1 1464273299 1464273299 1464273298
1464273595 300<br>
- VCL_call BACKEND_RESPONSE<br>
- TTL VCL 120 10 0 1464273299<br>
- VCL_return deliver<br>
- Storage malloc Transient<br>
- ObjProtocol HTTP/1.0<br>
- ObjStatus 200<br>
- ObjReason OK<br>
- ObjHeader Content-Length: 257701<br>
- ObjHeader Expires: Thu, 26 May 2016 14:39:55 GMT<br>
- ObjHeader Vary: X-CLIENT-COUNTRY, Cookie<br>
- ObjHeader X-CLIENT-COUNTRY: IN<br>
- ObjHeader Last-Modified: Thu, 26 May 2016 14:34:55 GMT<br>
- ObjHeader Cache-Control: max-age=300<br>
- ObjHeader Date: Thu, 26 May 2016 14:34:58 GMT<br>
- ObjHeader X-Frame-Options: SAMEORIGIN<br>
- ObjHeader Content-Type: text/html; charset=utf-8<br>
- ObjHeader Set-Cookie: jivaana_num_basket_items=;
expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/<br>
- Fetch_Body 3 length stream<br>
- BackendClose 21 boot.uwsgi<br>
- Timestamp BerespBody: 1464273298.512453 0.017923 0.004513<br>
- Length 257701<br>
- BereqAcct 1396 0 1396 415 257701 258116<br>
- End <br>
<br>
* << Request >> 65541 <br>
- Begin req 65540 rxreq<br>
- Timestamp Start: 1464273298.494400 0.000000 0.000000<br>
- Timestamp Req: 1464273298.494400 0.000000 0.000000<br>
- ReqStart 127.0.0.1 43438<br>
- ReqMethod GET<br>
- ReqURL /heels/<br>
- ReqProtocol HTTP/1.0<br>
- ReqHeader X-CLIENT-COUNTRY: IN<br>
- ReqHeader Host: varnish_staging<br>
- ReqHeader Connection: close<br>
- ReqHeader Cache-Control: max-age=0<br>
- ReqHeader Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8<br>
- ReqHeader Upgrade-Insecure-Requests: 1<br>
- ReqHeader User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS
X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/50.0.2661.102 Safari/537.36<br>
- ReqHeader Referer: <a class="moz-txt-link-freetext" href="http://test.jivaana.in/juttis/">http://test.jivaana.in/juttis/</a><br>
- ReqHeader Accept-Encoding: gzip, deflate, sdch<br>
- ReqHeader Accept-Language: en-US,en;q=0.8<br>
- ReqHeader Cookie:
_xsrf=2|f25d8caf|ffacf1c86b71827915f94aed8e9aeace|1462920275;
jivaana_country=IN; pagemap=0,0,0,0,0,1,0';
mp_774636c1ed2371eaf99455f71871069c_mixpanel=%7B%22distinct_id%22%3A%20%221518b8ba6c314b-04bd3d4-6b1b237b-100200-1518b8ba6c428a%22%2C%22%24i<br>
- ReqHeader X-Forwarded-For: 127.0.0.1<br>
- VCL_call RECV<br>
- VCL_return pass<br>
- VCL_call HASH<br>
- VCL_return lookup<br>
- VCL_call PASS<br>
- VCL_return fetch<br>
- Link bereq 65542 pass<br>
- Timestamp Fetch: 1464273298.508162 0.013762 0.013762<br>
- RespProtocol HTTP/1.0<br>
- RespStatus 200<br>
- RespReason OK<br>
- RespHeader Content-Length: 257701<br>
- RespHeader Expires: Thu, 26 May 2016 14:39:55 GMT<br>
- RespHeader Vary: X-CLIENT-COUNTRY, Cookie<br>
- RespHeader X-CLIENT-COUNTRY: IN<br>
- RespHeader Last-Modified: Thu, 26 May 2016 14:34:55 GMT<br>
- RespHeader Cache-Control: max-age=300<br>
- RespHeader Date: Thu, 26 May 2016 14:34:58 GMT<br>
- RespHeader X-Frame-Options: SAMEORIGIN<br>
- RespHeader Content-Type: text/html; charset=utf-8<br>
- RespHeader Set-Cookie: jivaana_num_basket_items=;
expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/<br>
- RespProtocol HTTP/1.1<br>
- RespHeader X-Varnish: 65541<br>
- RespHeader Age: 0<br>
- RespHeader Via: 1.1 varnish-v4<br>
- VCL_call DELIVER<br>
- VCL_return deliver<br>
- Timestamp Process: 1464273298.508196 0.013796 0.000034<br>
- RespHeader Accept-Ranges: bytes<br>
- Debug "RES_MODE 2"<br>
- RespHeader Connection: close<br>
- Timestamp Resp: 1464273298.512479 0.018080 0.004284<br>
- ReqAcct 1369 0 1369 503 257701 258204<br>
- End <br>
<br>
* << Session >> 65540 <br>
- Begin sess 0 HTTP/1<br>
- SessOpen 127.0.0.1 43438 0.0.0.0:9003 127.0.0.1 9003
1464273298.494343 20<br>
- Link req 65541 rxreq<br>
- SessClose RESP_CLOSE 0.018<br>
- End <br>
<br>
<u><b>For the logged out user:</b></u><br>
<br>
* << BeReq >> 32788 <br>
- Begin bereq 32787 fetch<br>
- Timestamp Start: 1464273406.124375 0.000000 0.000000<br>
- BereqMethod GET<br>
- BereqURL /heels/<br>
- BereqProtocol HTTP/1.0<br>
- BereqHeader X-CLIENT-COUNTRY: IN<br>
- BereqHeader Host: varnish_staging<br>
- BereqHeader Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8<br>
- BereqHeader Upgrade-Insecure-Requests: 1<br>
- BereqHeader User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS
X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/50.0.2661.102 Safari/537.36<br>
- BereqHeader Referer: <a class="moz-txt-link-freetext" href="http://test.jivaana.in/home">http://test.jivaana.in/home</a><br>
- BereqHeader Accept-Language: en-US,en;q=0.8<br>
- BereqHeader X-Forwarded-For: 127.0.0.1<br>
- BereqHeader Accept-Encoding: gzip<br>
- BereqProtocol HTTP/1.1<br>
- BereqHeader X-Varnish: 32788<br>
- VCL_call BACKEND_FETCH<br>
- VCL_return fetch<br>
- BackendOpen 21 boot.uwsgi 127.0.0.1 7090 127.0.0.1 57794<br>
- Timestamp Bereq: 1464273406.124744 0.000369 0.000369<br>
- Timestamp Beresp: 1464273406.137721 0.013346 0.012977<br>
- BerespProtocol HTTP/1.1<br>
- BerespStatus 200<br>
- BerespReason OK<br>
- BerespHeader Content-Length: 257701<br>
- BerespHeader Expires: Thu, 26 May 2016 14:39:55 GMT<br>
- BerespHeader Vary: X-CLIENT-COUNTRY, Cookie<br>
- BerespHeader X-CLIENT-COUNTRY: IN<br>
- BerespHeader Last-Modified: Thu, 26 May 2016 14:34:55 GMT<br>
- BerespHeader Cache-Control: max-age=300<br>
- BerespHeader Date: Thu, 26 May 2016 14:36:46 GMT<br>
- BerespHeader X-Frame-Options: SAMEORIGIN<br>
- BerespHeader Content-Type: text/html; charset=utf-8<br>
- BerespHeader Set-Cookie: jivaana_num_basket_items=;
expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/<br>
- TTL RFC 300 10 -1 1464273406 1464273406 1464273406
1464273595 300<br>
- VCL_call BACKEND_RESPONSE<br>
- BerespUnset Set-Cookie: jivaana_num_basket_items=;
expires=Thu, 01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/<br>
- VCL_Log Caching the url : **********************/heels/<br>
- VCL_return deliver<br>
- Storage file s0<br>
- ObjProtocol HTTP/1.1<br>
- ObjStatus 200<br>
- ObjReason OK<br>
- ObjHeader Content-Length: 257701<br>
- ObjHeader Expires: Thu, 26 May 2016 14:39:55 GMT<br>
- ObjHeader Vary: X-CLIENT-COUNTRY, Cookie<br>
- ObjHeader X-CLIENT-COUNTRY: IN<br>
- ObjHeader Last-Modified: Thu, 26 May 2016 14:34:55 GMT<br>
- ObjHeader Cache-Control: max-age=300<br>
- ObjHeader Date: Thu, 26 May 2016 14:36:46 GMT<br>
- ObjHeader X-Frame-Options: SAMEORIGIN<br>
- ObjHeader Content-Type: text/html; charset=utf-8<br>
- Fetch_Body 3 length stream<br>
- BackendReuse 21 boot.uwsgi<br>
- Timestamp BerespBody: 1464273406.139210 0.014835 0.001489<br>
- Length 257701<br>
- BereqAcct 457 0 457 415 257701 258116<br>
- End <br>
<br>
* << Request >> 32787 <br>
- Begin req 32786 rxreq<br>
- Timestamp Start: 1464273406.124217 0.000000 0.000000<br>
- Timestamp Req: 1464273406.124217 0.000000 0.000000<br>
- ReqStart 127.0.0.1 43449<br>
- ReqMethod GET<br>
- ReqURL /heels/<br>
- ReqProtocol HTTP/1.0<br>
- ReqHeader X-CLIENT-COUNTRY: IN<br>
- ReqHeader Host: varnish_staging<br>
- ReqHeader Connection: close<br>
- ReqHeader Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8<br>
- ReqHeader Upgrade-Insecure-Requests: 1<br>
- ReqHeader User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS
X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/50.0.2661.102 Safari/537.36<br>
- ReqHeader Referer: <a class="moz-txt-link-freetext" href="http://test.jivaana.in/home">http://test.jivaana.in/home</a><br>
- ReqHeader Accept-Encoding: gzip, deflate, sdch<br>
- ReqHeader Accept-Language: en-US,en;q=0.8<br>
- ReqHeader Cookie:
_xsrf=2|f25d8caf|ffacf1c86b71827915f94aed8e9aeace|1462920275;
jivaana_country=IN; pagemap=0,0,0,0,0,1,0'; _gat=1;
csrftoken=PFm9lTAeFcQLIHY2UsUjkuO73R1GVaxn;
_ga=GA1.2.886266615.1446454138;
mp_774636c1ed2371eaf99455f71871069c_mixpanel=%7B%22disti<br>
- ReqHeader X-Forwarded-For: 127.0.0.1<br>
- VCL_call RECV<br>
- ReqUnset Cookie:
_xsrf=2|f25d8caf|ffacf1c86b71827915f94aed8e9aeace|1462920275;
jivaana_country=IN; pagemap=0,0,0,0,0,1,0'; _gat=1;
csrftoken=PFm9lTAeFcQLIHY2UsUjkuO73R1GVaxn;
_ga=GA1.2.886266615.1446454138;
mp_774636c1ed2371eaf99455f71871069c_mixpanel=%7B%22disti<br>
- VCL_return hash<br>
- ReqUnset Accept-Encoding: gzip, deflate, sdch<br>
- ReqHeader Accept-Encoding: gzip<br>
- VCL_call HASH<br>
- VCL_return lookup<br>
- VCL_call MISS<br>
- VCL_return fetch<br>
- Link bereq 32788 fetch<br>
- Timestamp Fetch: 1464273406.138165 0.013947 0.013947<br>
- RespProtocol HTTP/1.1<br>
- RespStatus 200<br>
- RespReason OK<br>
- RespHeader Content-Length: 257701<br>
- RespHeader Expires: Thu, 26 May 2016 14:39:55 GMT<br>
- RespHeader Vary: X-CLIENT-COUNTRY, Cookie<br>
- RespHeader X-CLIENT-COUNTRY: IN<br>
- RespHeader Last-Modified: Thu, 26 May 2016 14:34:55 GMT<br>
- RespHeader Cache-Control: max-age=300<br>
- RespHeader Date: Thu, 26 May 2016 14:36:46 GMT<br>
- RespHeader X-Frame-Options: SAMEORIGIN<br>
- RespHeader Content-Type: text/html; charset=utf-8<br>
- RespHeader X-Varnish: 32787<br>
- RespHeader Age: 0<br>
- RespHeader Via: 1.1 varnish-v4<br>
- VCL_call DELIVER<br>
- VCL_return deliver<br>
- Timestamp Process: 1464273406.138211 0.013993 0.000046<br>
- RespHeader Accept-Ranges: bytes<br>
- Debug "RES_MODE 2"<br>
- RespHeader Connection: close<br>
- Timestamp Resp: 1464273406.139451 0.015234 0.001240<br>
- ReqAcct 1119 0 1119 405 257701 258106<br>
- End <br>
<br>
* << Session >> 32786 <br>
- Begin sess 0 HTTP/1<br>
- SessOpen 127.0.0.1 43449 0.0.0.0:9003 127.0.0.1 9003
1464273406.124096 16<br>
- Link req 32787 rxreq<br>
- SessClose RESP_CLOSE 0.016<br>
- End <br>
<br>
<br>
Thanks,<br>
Pinakee<br>
<br>
<br>
<div class="moz-cite-prefix">On 26/05/16 7:58 pm, Guillaume Quintard
wrote:<br>
</div>
<blockquote
cite="mid:CAJ6ZYQz5L6EsZzn=9ttuHWgkECbMWbPhKbiN=2H3HOVRtjrTFg@mail.gmail.com"
type="cite">
<div dir="ltr">Are you able to isolate the faulty request in
varnishlog? The one that should be passed and isn't?</div>
<div class="gmail_extra"><br clear="all">
<div>
<div class="gmail_signature">
<div dir="ltr">
<div>-- <br>
</div>
Guillaume Quintard<br>
</div>
</div>
</div>
<br>
<div class="gmail_quote">On Thu, May 26, 2016 at 4:07 PM,
Pinakee BIswas <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:pinakee@waltzz.com" target="_blank">pinakee@waltzz.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<p>Further adding the observations with the following
scenario:</p>
<ol>
<li>Visit URL A-not-loggedin</li>
<li>Visit URL B-not-loggedin</li>
<li>User logs in</li>
<li>Visit URL A after logging in - varnish is serving
the page - A-not-loggedin</li>
<li>Visit URL B after logging in - varnish is serving
the page B-not-loggedin</li>
</ol>
<p>This means Varnish is serving the pages just visited
(till cache expiry) irrespective of the fact that the
page is being fetched from backend and that there is a
pass in vcl_recv.</p>
<p>I am unable to understand the above mentioned behavior
- the VCL logic I used is simple as mentioned in the
mail below. <br>
</p>
<p>Regards,</p>
<p>Pinakee<br>
</p>
<div>
<div class="h5"> <br>
<div>On 26/05/16 6:24 pm, Pinakee BIswas wrote:<br>
</div>
<blockquote type="cite">Hi, <br>
<br>
I am facing a strange problem with Varnish cache.
Ours is an ecommerce site wherein users can visit
with or without logging in. I have written the VCL
to unset cookies when user not logged in. <br>
<br>
The scenario is user logs in and then logs out. When
the user logs out, Varnish is still delivering
logged in pages to the user which is strange as the
requests for logged in users go all the way to the
backend and the pages are not supposed to get
cached. I have been looking into this since quite
some time and still not able to figure out the
reason. <br>
<br>
Would appreciate any help. <br>
<br>
Thanks, <br>
<br>
Pinakee <br>
<br>
PFA the output from varnishlog. <br>
<br>
Following is the VCL code: <br>
<br>
sub vcl_recv { <br>
# Happens before we check if we have this in
cache already. <br>
# <br>
# Typically you clean up the request here,
removing cookies you don't need, <br>
# rewriting the request, etc. <br>
set req.backend_hint = uwsgi; <br>
<br>
if (req.method == "GET") { <br>
if ((req.http.Cookie !~ "sessionid=")
&& <br>
(req.http.Cookie !~ "loggedin_user=")
&& <br>
(req.url !~ "^/esi")) { <br>
unset req.http.cookie; # strip the
cookies - we don't need them <br>
} <br>
} <br>
} <br>
<br>
sub vcl_backend_response { <br>
# Happens after we have read the response
headers from the backend. <br>
# <br>
# Here you clean the response headers, removing
silly Set-Cookie headers <br>
# and other mistakes your backend does. <br>
if (bereq.method == "GET") { <br>
set beresp.do_esi = true; <br>
if ((beresp.http.Set-Cookie !~
"jivaana_user=") && <br>
(beresp.http.Set-Cookie !~
"sessionid=") && <br>
(bereq.http.Cookie !~ "sessionid=")
&& <br>
(bereq.http.Cookie !~
"jivaana_user=") && <br>
(bereq.url !~
"^/product/addtobasket")) { <br>
#unset beresp.http.Set-Cookie; <br>
set beresp.uncacheable = false; <br>
return(deliver); <br>
} <br>
} <br>
} <br>
<br>
</blockquote>
<br>
</div>
</div>
</div>
<br>
_______________________________________________<br>
varnish-misc mailing list<br>
<a moz-do-not-send="true"
href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a><br>
<a moz-do-not-send="true"
href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc"
rel="noreferrer" target="_blank">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a><br>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>