<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi All, <br>
<br>
I think it was due to the nature of the website, (i.e. cookies +
json updates) were playing role not to cache.<br>
I did some changes and it started working (for forced cache rule.)<br>
<br>
e.g. sub vcl_recv -> added some lookup for certain conditions.<br>
and sub vcl_fetch -> added set beresp.ttl<br>
<br>
But going into another type of trouble: i occasionally get 503
thrown without any reason.<br>
I have 2 server, i intentionally turned one off, health checkup
shows its sick (great), and sends request to alive one, but 1 out
of 20 times it throws 503.<br>
<br>
<u><small>[I have added ulimit -n 10000 and restart for 4 times in
503, however is there any particular reason behind this
behaviour?]<br>
</small></u><br>
4 RxURL c /json/showcase/<br>
4 RxProtocol c HTTP/1.1<br>
4 RxHeader c Host: <a moz-do-not-send="true"
class="moz-txt-link-abbreviated" href="http://www.example.com">www.example.com</a><br>
4 RxHeader c X-Real-IP: 188.223.122.81<br>
4 RxHeader c X-Forwarded-For: 188.223.122.81<br>
4 RxHeader c X-Forwarded-Proto: http<br>
4 RxHeader c User-Agent: Mozilla/5.0 (Windows NT 6.1;
WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64
Safari/537.31<br>
4 RxHeader c Accept: */*<br>
4 RxHeader c Referer: <a moz-do-not-send="true"
class="moz-txt-link-freetext" href="http://www.example.com/">http://www.example.com/</a><br>
4 RxHeader c Accept-Encoding: gzip,deflate,sdch<br>
4 RxHeader c Accept-Language: en-US,en;q=0.8<br>
4 RxHeader c Accept-Charset:
ISO-8859-1,utf-8;q=0.7,*;q=0.3<br>
4 VCL_call c recv<br>
4 VCL_acl c NO_MATCH unwanted<br>
4 VCL_return c pass<br>
4 VCL_call c hash<br>
4 Hash c /json/showcase/<br>
4 Hash c <a moz-do-not-send="true"
class="moz-txt-link-abbreviated" href="http://www.example.com">www.example.com</a><br>
4 VCL_return c hash<br>
4 VCL_call c pass pass<br>
4 FetchError c no backend connection<br>
4 VCL_call c error deliver<br>
4 VCL_call c deliver deliver<br>
4 TxProtocol c HTTP/1.1<br>
4 TxStatus c 503<br>
4 TxResponse c Service Unavailable<br>
4 TxHeader c Server: Varnish<br>
4 TxHeader c Content-Type: text/html; charset=utf-8<br>
4 TxHeader c Content-Length: 715<br>
4 TxHeader c Accept-Ranges: bytes<br>
4 TxHeader c Date: Sat, 27 Apr 2013 15:51:25 GMT<br>
4 TxHeader c X-Varnish: 619632706<br>
4 TxHeader c Age: 0<br>
4 TxHeader c Via: 1.1 varnish<br>
4 TxHeader c Connection: close<br>
4 Length c 715 <br>
<br>
<br>
<br>
On 27/04/2013 12:51, Ashish wrote:<br>
</div>
<blockquote cite="mid:BLU0-SMTP322056D1897D56AD82E74ECA0B00@phx.gbl"
type="cite">Hi , I am quite new on varnish, so far its been really
impressive doing test and quite everything that i wanted to
achieve with it,
<br>
I did some test with single server, and everything looked good,
interms of cache hit ratio and all. but now i am unable to see
anything as such as cache at all.
<br>
<br>
Could anyone please show me pointer what in my rule is causing not
to cache?
<br>
<br>
( Things not working so far)
<br>
# Cache as wished: /json/showcase 1s , robot.txt 4 days,
CSS/JPG/JS/ 3600s
<br>
# If everything is busted serve whatever we got for 6 h
<br>
<br>
<br>
=> vcl
<br>
<br>
################## Define Backend Servers
##########################################
<br>
backend box1 { .host = "xx.xx.xx.xx"; .probe = { .url = "/";
.timeout = 34 ms; .interval = 3s; .window = 5; .threshold = 3;
} }
<br>
backend box2 { .host = "xx.xx.xx.xx"; .probe = { .url = "/";
.timeout = 34 ms; .interval = 3s; .window = 5; .threshold = 3;
} }
<br>
<br>
acl unwanted { "188.223.122.81"; }
<br>
<br>
sub vcl_recv { if (client.ip ~ unwanted) { error 403 "You seem to
be blocked man.";}
<br>
<br>
if
(req.http.user-agent ~ "^someuseragent") {
<br>
error 403 "If you think This is Mistake Please use
different User-Agent..";}
<br>
}
<br>
<br>
<br>
####################################### Start of Load Balancing
########################
<br>
<br>
director my_cluster random {
<br>
<br>
{ .backend = box1; .weight = 2; }
<br>
{ .backend = box2; .weight = 2; }
<br>
}
<br>
<br>
###################################### ENd of Load Balancing
############################
<br>
<br>
###################################### Start of Request Handling
########################
<br>
#sub vcl_recv {
<br>
if (req.http.host ~ "^(.*\.)?myweb\.com$") {
<br>
set req.backend = my_cluster;
<br>
}
<br>
<br>
if (req.request != "GET" &&
<br>
req.request != "HEAD" &&
<br>
req.request != "PUT" &&
<br>
req.request != "POST" &&
<br>
req.request != "TRACE" &&
<br>
req.request != "OPTIONS" &&
<br>
req.request != "DELETE") {
<br>
/* Non-RFC2616 or CONNECT which is weird.
*/
<br>
return (pipe);
<br>
}
<br>
if (req.request != "GET" &&
req.request != "HEAD") {
<br>
/* We only deal with GET and HEAD by
default */
<br>
return (pass);
<br>
}
<br>
if (req.http.Authorization || req.http.Cookie)
{
<br>
/* Not cacheable by default */
<br>
return (pass);
<br>
}
<br>
if (req.request == "GET" || req.request ==
"HEAD") {
<br>
return (lookup);
<br>
}
<br>
}
<br>
<br>
####################################### DO not cache anything on
probe ##############
<br>
<br>
<br>
sub vcl_recv {
<br>
# This box fqdn is diff then above actual domains
<br>
if (req.http.host ~ "^(.*\.)?\.myboxes\.com$") {
<br>
return(pass);
<br>
}
<br>
}
<br>
<br>
######################################### Start of forced TTL
############################
<br>
sub vcl_fetch {
<br>
if (req.url ~ "/json/showcase") {
<br>
set beresp.ttl = 1s;
<br>
}
<br>
<br>
<br>
if (beresp.http.cache-control !~ "s-maxage"
&& req.url ~ "\.(png|gif|jpg)$") {
<br>
set beresp.ttl = 120s;
<br>
}
<br>
<br>
if(req.url == "/robots.txt") {
<br>
# Robots.txt is updated rarely and should be
cached for 4 days
<br>
# Purge manually as required
<br>
set beresp.ttl = 96h;
<br>
}
<br>
<br>
# Set TTL for these product
<br>
if (req.url ~
"\.(png|gif|jpeg|jpg|ico|swf|css|js|html|htm)$") {
<br>
unset beresp.http.set-cookie;
<br>
set beresp.ttl = 3600s;
<br>
}
<br>
<br>
# Allow items to be stale if needed (i.e. if we are
down server wise).
<br>
set beresp.grace = 6h;
<br>
}
<br>
<br>
<br>
_______________________________________________
<br>
varnish-misc mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:varnish-misc@varnish-cache.org">varnish-misc@varnish-cache.org</a>
<br>
<a class="moz-txt-link-freetext" href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc">https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc</a>
<br>
<br>
<br>
</blockquote>
<br>
</body>
</html>