Thanks Paul <div><br></div><div>Oh yes my fault , my varnish server open files 1024 , i guess my problem solved , thx a lot </div><div><br></div><div><br></div><div><br></div><div>Thanks</div><div><br></div><div>TW</div><div>
<br></div><div><br><br><div class="gmail_quote">On Wed, Sep 23, 2009 at 4:45 AM, pub crawler <span dir="ltr"><<a href="http://pubcrawler.com">pubcrawler.com</a>@<a href="http://gmail.com">gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Well I might be a bit off on this, but 503's often involve ulimit<br>
ceiling maximums being hit and exceeded.<br>
<br>
ulimit -a<br>
<br>
What is that limit set at for open files?<br>
<br>
In our experience many high performance web related software products<br>
suffer from low open file limit. I've seen 256 in SunOS, 1024 in<br>
Ubuntu. We bump our settings in startup scripts for key servers to<br>
8096. We run on dedicated servers - so no resource contention with<br>
other users.<br>
<br>
-Paul<br>
<div><div></div><div class="h5"><br>
On 9/22/09, M L <<a href="mailto:ml@tinwong.com">ml@tinwong.com</a>> wrote:<br>
> Hi list<br>
><br>
><br>
> I love varnish and really want to use it :D Any clue to fix my problem , it<br>
> come out alot backend fail ( i guess timeout problem )<br>
><br>
> my setup<br>
><br>
> 1.Centos 5.3 64bit varnish / webserver<br>
> 2.nginx backend server (it run over 200+days 2Mil pv/day without any problem<br>
> & healthy hardware)<br>
> 3.varnish connect to nginx in same internal switchs (3com 5500 Giga layer4)<br>
> 4.Tested different version nginx was same happen ( nginx-0.6.36 &<br>
> nginx-0.7.61)<br>
> 5.Tested 2 different hardware for varnish same happen<br>
> 6.Changed nginx different timeout same happen , if changed to keepalive 0<br>
> will more backend fail<br>
> 7.When i changed vcl to director rr x50 times , it didnt show 503 Service<br>
> Unavailable on client side but like 2-8 sec. lag when then Backend fail<br>
> number increase<br>
><br>
><br>
> #start<br>
><br>
> varnishd -p lru_interval=3600 -a <a href="http://0.0.0.0:80" target="_blank">0.0.0.0:80</a> -T localhost:3500 -p<br>
> client_http11=on -f vconf2 -s file,/usr/local/varnish/cache.bin,80G -h<br>
> classic,500009 -p listen_depth=4096 -p obj_workspace=32768 -p<br>
> sess_workspace=32768 -p send_timeout=327 -p first_byte_timeout=300 -p<br>
> connect_timeout=5 -p vcl_trace=on<br>
><br>
><br>
><br>
> #varnishlog<br>
><br>
> 140 ReqStart c 121.203.78.124 4755 1383283991<br>
> 140 RxRequest c GET<br>
> 140 RxURL c /thread-1131553-1-1.html<br>
> 140 RxProtocol c HTTP/1.1<br>
> 140 RxHeader c Host: <a href="http://www.zoobar.com" target="_blank">www.zoobar.com</a><br>
> 140 RxHeader c User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1;<br>
> zh-TW; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14<br>
> 140 RxHeader c Accept: image/png,image/*;q=0.8,*/*;q=0.5<br>
> 140 RxHeader c Accept-Language: zh-tw,en-us;q=0.7,en;q=0.3<br>
> 140 RxHeader c Accept-Encoding: gzip,deflate<br>
> 140 RxHeader c Accept-Charset: Big5,utf-8;q=0.7,*;q=0.7<br>
> 140 RxHeader c Keep-Alive: 300<br>
> 140 RxHeader c Connection: keep-alive<br>
> 140 RxHeader c Referer: <a href="http://www.zoobar.com/thread-1131553-1-1.html" target="_blank">http://www.zoobar.com/thread-1131553-1-1.html</a><br>
> 140 RxHeader c Cookie: cdb_sid=Nf6FM3;<br>
> cdb_oldtopics=D1131553D1131773D1129353D1129581D1130425D1131274D1121699D1122534D1122581D1124932D1125704D1126044D1126641D1126650D1127247D1128227D1128288D1128329D1128640D1129165D1129403D1130965D1131013D1131057D1131460D1131464D1131491D<br>
> 140 VCL_call c recv<br>
> 140 VCL_trace c 1 106.14<br>
> 140 VCL_trace c 2 110.5<br>
> 140 VCL_trace c 3 110.41<br>
> 140 VCL_trace c 9 143.5<br>
> 140 VCL_trace c 14 157.1<br>
> 140 VCL_trace c 15 157.5<br>
> 140 VCL_trace c 17 162.1<br>
> 140 VCL_trace c 18 162.5<br>
> 140 VCL_trace c 26 172.9<br>
> 140 VCL_trace c 27 172.13<br>
> 140 VCL_trace c 30 180.1<br>
> 140 VCL_trace c 31 180.5<br>
> 140 VCL_trace c 33 184.1<br>
> 140 VCL_trace c 34 184.5<br>
> 140 VCL_trace c 36 192.1<br>
> 140 VCL_trace c 37 192.5<br>
> 140 VCL_trace c 39 198.1<br>
> 140 VCL_trace c 40 198.5<br>
> 140 VCL_trace c 41 198.31<br>
> 140 VCL_trace c 42 199.9<br>
> 140 VCL_trace c 44 202.18<br>
> 140 VCL_trace c 45 202.53<br>
> 140 VCL_trace c 49 213.1<br>
> 140 VCL_trace c 84 42.14<br>
> 140 VCL_trace c 85 43.9<br>
> 140 VCL_trace c 93 53.5<br>
> 140 VCL_trace c 94 53.9<br>
> 140 VCL_trace c 97 57.5<br>
> 140 VCL_trace c 98 57.9<br>
> 140 VCL_trace c 99 57.35<br>
> 140 VCL_trace c 100 57.52<br>
> 140 VCL_return c pass<br>
> 140 VCL_call c pass<br>
> 140 VCL_trace c 103 74.14<br>
> 140 VCL_return c pass<br>
> 140 VCL_call c error<br>
> 140 VCL_trace c 124 129.15<br>
> 140 VCL_return c deliver<br>
> 140 Length c 466<br>
> 140 VCL_call c deliver<br>
> 140 VCL_trace c 69 327.17<br>
> 140 VCL_trace c 70 328.21<br>
> 140 VCL_trace c 75 344.1<br>
> 140 VCL_trace c 120 110.17<br>
> 140 VCL_return c deliver<br>
> 140 TxProtocol c HTTP/1.1<br>
> 140 TxStatus c 503<br>
> 140 TxResponse c Service Unavailable<br>
> 140 TxHeader c Server: Varnish<br>
> 140 TxHeader c Retry-After: 0<br>
> 140 TxHeader c Content-Type: text/html; charset=utf-8<br>
> 140 TxHeader c Content-Length: 466<br>
> 140 TxHeader c Date: Tue, 22 Sep 2009 16:15:52 GMT<br>
> 140 TxHeader c X-Varnish: 1383283991<br>
> 140 TxHeader c Age: 0<br>
> 140 TxHeader c Via: 1.1 varnish<br>
> 140 TxHeader c Connection: close<br>
> 140 ReqEnd c 1383283991 1253636152.715658903 1253636152.715944052<br>
> 0.016985893 0.000265121 0.000020027<br>
> 140 SessionClose c error<br>
> 140 StatSess c 121.203.78.124 4755 0 1 1 0 1 0 235 466<br>
><br>
><br>
><br>
><br>
> #varnishstat -1<br>
><br>
> uptime 266 . Child uptime<br>
> client_conn 13993 52.61 Client connections accepted<br>
> client_req 43378 163.08 Client requests received<br>
> cache_hit 31219 117.36 Cache hits<br>
> cache_hitpass 86 0.32 Cache hits for pass<br>
> cache_miss 3523 13.24 Cache misses<br>
> backend_conn 12054 45.32 Backend connections success<br>
> backend_unhealthy 0 0.00 Backend connections not<br>
> attempted<br>
> backend_busy 0 0.00 Backend connections too many<br>
> backend_fail 5900 22.18 Backend connections failures<br>
> backend_reuse 3503 13.17 Backend connections reuses<br>
> backend_recycle 11552 43.43 Backend connections recycles<br>
> backend_unused 0 0.00 Backend connections unused<br>
> n_srcaddr 1246 . N struct srcaddr<br>
> n_srcaddr_act 64 . N active struct srcaddr<br>
> n_sess_mem 974 . N struct sess_mem<br>
> n_sess 84 . N struct sess<br>
> n_object 3040 . N struct object<br>
> n_objecthead 1972 . N struct objecthead<br>
> n_smf 6460 . N struct smf<br>
> n_smf_frag 573 . N small free smf<br>
> n_smf_large 7 . N large free smf<br>
> n_vbe_conn 119 . N struct vbe_conn<br>
> n_bereq 240 . N struct bereq<br>
> n_wrk 261 . N worker threads<br>
> n_wrk_create 261 0.98 N worker threads created<br>
> n_wrk_failed 0 0.00 N worker threads not created<br>
> n_wrk_max 336496 1265.02 N worker threads limited<br>
> n_wrk_queue 0 0.00 N queued work requests<br>
> n_wrk_overflow 4696 17.65 N overflowed work requests<br>
> n_wrk_drop 374 1.41 N dropped work requests<br>
> n_backend 60 . N backends<br>
> n_expired 675 . N expired objects<br>
> n_lru_nuked 0 . N LRU nuked objects<br>
> n_lru_saved 0 . N LRU saved objects<br>
> n_lru_moved 0 . N LRU moved objects<br>
> n_deathrow 0 . N objects on deathrow<br>
> losthdr 0 0.00 HTTP header overflows<br>
> n_objsendfile 0 0.00 Objects sent with sendfile<br>
> n_objwrite 41590 156.35 Objects sent with write<br>
> n_objoverflow 0 0.00 Objects overflowing workspace<br>
> s_sess 10425 39.19 Total Sessions<br>
> s_req 43325 162.88 Total Requests<br>
> s_pipe 0 0.00 Total pipe<br>
> s_pass 8542 32.11 Total pass<br>
> s_fetch 11996 45.10 Total fetch<br>
> s_hdrbytes 16332373 61399.90 Total header bytes<br>
> s_bodybytes 266640005 1002406.03 Total body bytes<br>
> sess_closed 2116 7.95 Session Closed<br>
> sess_pipeline 54 0.20 Session Pipeline<br>
> sess_readahead 34 0.13 Session Read Ahead<br>
> sess_linger 0 0.00 Session Linger<br>
> sess_herd 41284 155.20 Session herd<br>
> shm_records 3806411 14309.82 SHM records<br>
> shm_writes 134677 506.30 SHM writes<br>
> shm_flushes 40 0.15 SHM flushes due to overflow<br>
> shm_cont 884 3.32 SHM MTX contention<br>
> shm_cycles 1 0.00 SHM cycles through buffer<br>
> sm_nreq 24335 91.48 allocator requests<br>
> sm_nobj 5880 . outstanding allocations<br>
> sm_balloc 129392640 . bytes allocated<br>
> sm_bfree 85769953280 . bytes free<br>
> sma_nreq 0 0.00 SMA allocator requests<br>
> sma_nobj 0 . SMA outstanding allocations<br>
> sma_nbytes 0 . SMA outstanding bytes<br>
> sma_balloc 0 . SMA bytes allocated<br>
> sma_bfree 0 . SMA bytes free<br>
> sms_nreq 111 0.42 SMS allocator requests<br>
> sms_nobj 0 . SMS outstanding allocations<br>
> sms_nbytes 0 . SMS outstanding bytes<br>
> sms_balloc 50376 . SMS bytes allocated<br>
> sms_bfree 50376 . SMS bytes freed<br>
> backend_req 12054 45.32 Backend requests made<br>
> n_vcl 1 0.00 N vcl total<br>
> n_vcl_avail 1 0.00 N vcl available<br>
> n_vcl_discard 0 0.00 N vcl discarded<br>
> n_purge 1 . N total active purges<br>
> n_purge_add 1 0.00 N new purges added<br>
> n_purge_retire 0 0.00 N old purges deleted<br>
> n_purge_obj_test 0 0.00 N objects tested<br>
> n_purge_re_test 0 0.00 N regexps tested against<br>
> n_purge_dups 0 0.00 N duplicate purges removed<br>
> hcb_nolock 0 0.00 HCB Lookups without lock<br>
> hcb_lock 0 0.00 HCB Lookups with lock<br>
> hcb_insert 0 0.00 HCB Inserts<br>
> esi_parse 0 0.00 Objects ESI parsed (unlock)<br>
> esi_errors 0 0.00 ESI parse errors (unlock)<br>
><br>
><br>
> # my vcl<br>
><br>
> director srv1 round-robin {<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> { .backend = { .connect_timeout = 2s; .host = "10.0.0.5"; .port = "80";<br>
> } }<br>
> }<br>
><br>
><br>
> acl purge {<br>
><br>
> "localhost"; "127.0.0.1";<br>
> }<br>
><br>
> #recv<br>
> sub vcl_recv {<br>
><br>
> #set req.grace = 30s;<br>
><br>
> if (req.http.host ~ "<a href="http://www.zoobar.com" target="_blank">www.zoobar.com</a>") {<br>
> set req.http.host = "<a href="http://www.zoobar.com" target="_blank">www.zoobar.com</a>";<br>
> set req.backend = srv1;<br>
><br>
><br>
> }elseif ( req.http.host ~ "<a href="http://www.voobar.com" target="_blank">www.voobar.com</a>") {<br>
> set req.http.host = "<a href="http://www.voobar.com" target="_blank">www.voobar.com</a>";<br>
> set req.backend = srv1;<br>
><br>
><br>
> }elseif ( req.http.host ~ "<a href="http://www.hoobar.com" target="_blank">www.hoobar.com</a>") {<br>
> set req.http.host = "<a href="http://www.hoobar.com" target="_blank">www.hoobar.com</a>";<br>
> set req.backend = srv1;<br>
><br>
> }else{<br>
> error 401 "Bad Domain";<br>
> }<br>
><br>
> # Add a unique header containing the client address<br>
> remove req.http.X-Forwarded-For;<br>
> set req.http.X-Forwarded-For = client.ip;<br>
> # [...]<br>
><br>
><br>
> if (req.request == "PURGE") {<br>
> if(!client.ip ~ purge) {<br>
> error 405 "Not Allowed";<br>
> } lookup;}<br>
><br>
> if (req.http.Expect) {<br>
> pipe;<br>
> }<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>
> pipe;<br>
> }<br>
> if (req.request != "GET" && req.request != "HEAD") {<br>
> /* We only deal with GET and HEAD by default */<br>
> pass;<br>
> }<br>
><br>
><br>
><br>
><br>
> if (req.http.Cache-Control ~ "no-cache") {<br>
> pass;<br>
> }<br>
><br>
> if (req.http.Authenticate) {<br>
> pass;<br>
> }<br>
><br>
> #if (req.http.Cookie) {<br>
> # pass;<br>
> # }<br>
><br>
> if (req.url ~<br>
> "\.(zip|ico|dat|torrent|png|gif|jpg|swf|css|js|bmp|bz2|tbz|mp3|ogg)$") {<br>
> unset req.http.cookie;<br>
> lookup;<br>
> # unset req.http.authenticate;<br>
> }<br>
><br>
> if (req.http.Accept-Encoding) {<br>
> if (req.url ~<br>
> "\.(zip|ico|dat|torrent|png|gif|jpg|swf|css|js|bmp|bz2|tbz|mp3|ogg)$") {<br>
> # No point in compressing these<br>
> remove req.http.Accept-Encoding;<br>
> } elsif (req.http.Accept-Encoding ~ "gzip") {<br>
> set req.http.Accept-Encoding = "gzip";<br>
> } elsif (req.http.Accept-Encoding ~ "deflate") {<br>
> set req.http.Accept-Encoding = "deflate";<br>
> } else {<br>
> # unkown algorithm<br>
> remove req.http.Accept-Encoding;<br>
> }<br>
> }<br>
><br>
><br>
> } #end recv<br>
><br>
><br>
> sub vcl_hash {<br>
> set req.hash += req.url;<br>
> set req.hash += req.http.host;<br>
> #set req.hash += req.http.cookie;<br>
> #set req.hash += server.ip;<br>
> hash;<br>
> } #end hash<br>
><br>
><br>
> # strip the cookie before the image is inserted into cache.<br>
> sub vcl_fetch {<br>
><br>
> #set obj.grace = 30s;<br>
><br>
><br>
> if(obj.http.Set-Cookie){<br>
> pass;<br>
> }<br>
><br>
><br>
> if(obj.http.Pragma ~ "no-cache" ||<br>
> obj.http.Cache-Control ~ "no-cache" ||<br>
> obj.http.Cache-Control ~ "private"){<br>
> pass;<br>
> }<br>
><br>
><br>
> if (req.url ~<br>
> "\.(zip|ico|dat|torrent|png|gif|jpg|swf|css|js|bmp|bz2|tbz|mp3|ogg)$") {<br>
> unset obj.http.set-cookie;<br>
> set obj.ttl = 1w;<br>
> }<br>
><br>
><br>
><br>
><br>
> if (req.url ~<br>
> "\.(zip|ico|dat|torrent|png|gif|jpg|swf|css|js|bmp|bz2|tbz|mp3|ogg)$") {<br>
> unset obj.http.expires;<br>
> set obj.http.cache-control = "max-age=315360000, public";<br>
> set obj.ttl = 1w;<br>
> set obj.http.magicmarker = "1";<br>
> }<br>
><br>
><br>
> if (obj.status == 503) {<br>
><br>
> restart;<br>
> }<br>
><br>
><br>
> # if (obj.cacheable) {<br>
> # /* Remove Expires from backend, it's not long<br>
> enough */<br>
> # unset obj.http.expires;<br>
><br>
> # /* Set the clients TTL on this object */<br>
> # set obj.http.cache-control = "max-age=315360000,<br>
> public";<br>
><br>
> # /* Set how long Varnish will keep it */<br>
> # set obj.ttl = 1w;<br>
><br>
> # /* marker for vcl_deliver to reset Age: */<br>
> # set obj.http.magicmarker = "1";<br>
> # }<br>
><br>
><br>
> } #fetch end<br>
><br>
><br>
><br>
><br>
> sub vcl_deliver {<br>
> if (resp.http.magicmarker) {<br>
> /* Remove the magic marker */<br>
> unset resp.http.magicmarker;<br>
><br>
> /* By definition we have a fresh object */<br>
> set resp.http.age = "0";<br>
> if (obj.hits > 0) {<br>
> set resp.http.X-Cache = "HIT";<br>
> } else {<br>
> set resp.http.X-Cache = "MISS";<br>
> }<br>
><br>
> }<br>
><br>
><br>
> } #deliver end<br>
><br>
><br>
> sub vcl_pipe {<br>
> # <a href="http://varnish.projects.linpro.no/ticket/451" target="_blank">http://varnish.projects.linpro.no/ticket/451</a><br>
> # This forces every pipe request to be the first one.<br>
> set bereq.http.connection = "close";<br>
> } #pipe end<br>
><br>
><br>
> sub vcl_hit {<br>
> if (req.request == "PURGE") {<br>
> set obj.ttl = 0s;<br>
> error 200 "Purged.";<br>
> }<br>
><br>
> if (!obj.cacheable) {<br>
> pass;<br>
> }<br>
> deliver;<br>
> }<br>
><br>
><br>
><br>
><br>
> Thank you<br>
><br>
> TW<br>
><br>
</div></div></blockquote></div><br></div>