我已经build立了Apache和Varnish,没有涉及到特定的configuration(8080上的apache,80端口上的varnish)。 我还在光油中删除了Cookie,以确保Wordpress网站的最大caching。
该网站的工作,它加载等。 但看起来Varnish并没有caching任何东西。 当我打开Varnishstat时,我总是看到Hitrate比例为0; 还有很多“inf backend_busy”,“inf backend_reuse”等。 并没有accepted_connections。 这是一个示例:
0+00:00:00 Hitrate ratio: 0 0 0 Hitrate avg: 0.0000 0.0000 0.0000 146 0.00 inf backend_busy - Backend conn. too many 164 0.00 inf backend_reuse - Backend conn. reuses 16 0.00 inf backend_toolate - Backend conn. was closed 101 0.00 inf backend_recycle - Backend conn. recycles 47 0.00 inf backend_retry - Backend conn. retry 111 0.00 inf fetch_head - Fetch head
怎么来的?
更新:Varnishlog:
0 CLI - Rd ping 0 CLI - Wr 200 19 PONG 1394712509 1.0 0 CLI - Rd ping 0 CLI - Wr 200 19 PONG 1394712512 1.0 0 CLI - Rd ping 0 CLI - Wr 200 19 PONG 1394712515 1.0 13 BackendClose - default 13 BackendOpen b default 127.0.0.1 38776 127.0.0.1 8080 13 BackendXID b 1420058564 13 TxRequest b GET 13 TxURL b / 13 TxProtocol b HTTP/1.1 13 TxHeader b Host: www.test-mystreaming.it 13 TxHeader b Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 13 TxHeader b User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36 13 TxHeader b Accept-Language: en-US,en;q=0.8,it-IT;q=0.6,it;q=0.4 13 TxHeader b X-Forwarded-For: 2.229.61.20 13 TxHeader b X-Varnish: 1420058564 13 TxHeader b Accept-Encoding: gzip 13 RxProtocol b HTTP/1.1 13 RxStatus b 200 13 RxResponse b OK 13 RxHeader b Date: Thu, 13 Mar 2014 12:08:37 GMT 13 RxHeader b Server: Apache/2.2.22 (Ubuntu) 13 RxHeader b X-Powered-By: PHP/5.3.10-1ubuntu3.10 13 RxHeader b X-Pingback: http://www.test-mystreaming.it/xmlrpc.php 13 RxHeader b Vary: Accept-Encoding 13 RxHeader b Content-Encoding: gzip 13 RxHeader b Content-Length: 7682 13 RxHeader b Content-Type: text/html; charset=UTF-8 13 Fetch_Body b 4(length) cls 0 mklen 1 13 Length b 7682 13 BackendReuse b default 11 SessionOpen c 2.229.61.20 56012 :80 11 ReqStart c 2.229.61.20 56012 1420058564 11 RxRequest c GET 11 RxURL c / 11 RxProtocol c HTTP/1.1 11 RxHeader c Host: www.test-mystreaming.it 11 RxHeader c Connection: keep-alive 11 RxHeader c Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 11 RxHeader c User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36 11 RxHeader c Accept-Encoding: gzip,deflate,sdch 11 RxHeader c Accept-Language: en-US,en;q=0.8,it-IT;q=0.6,it;q=0.4 11 RxHeader c Cookie: wp-settings-1=m5%3Do%26m4%3Do%26hidetb%3D1%26m9%3Do%26m1%3Do%26imgsize%3Dfull%26editor%3Dhtml%26libraryContent%3Dbrowse; wp-settings-time-1=1394014590; _xyz_lbx_until=1; _xyz_lbx_pc=1; __utma=257699214.1231191244.1394014450.1394039099.1394709725.5 11 VCL_call c recv lookup 11 VCL_call c hash 11 Hash c / 11 Hash c www.test-mystreaming.it 11 VCL_return c hash 11 VCL_call c miss fetch 11 Backend c 13 default default 11 TTL c 1420058564 RFC 120 -1 -1 1394712518 0 1394712517 0 0 11 VCL_call c fetch deliver 11 ObjProtocol c HTTP/1.1 11 ObjResponse c OK 11 ObjHeader c Date: Thu, 13 Mar 2014 12:08:37 GMT 11 ObjHeader c Server: Apache/2.2.22 (Ubuntu) 11 ObjHeader c X-Powered-By: PHP/5.3.10-1ubuntu3.10 11 ObjHeader c X-Pingback: http://www.test-mystreaming.it/xmlrpc.php 11 ObjHeader c Vary: Accept-Encoding 11 ObjHeader c Content-Encoding: gzip 11 ObjHeader c Content-Type: text/html; charset=UTF-8 11 Gzip cu F - 7682 33861 80 80 61389 11 VCL_call c deliver deliver 11 TxProtocol c HTTP/1.1 11 TxStatus c 200 11 TxResponse c OK 11 TxHeader c Server: Apache/2.2.22 (Ubuntu) 11 TxHeader c X-Powered-By: PHP/5.3.10-1ubuntu3.10 11 TxHeader c X-Pingback: http://www.test-mystreaming.it/xmlrpc.php 11 TxHeader c Vary: Accept-Encoding 11 TxHeader c Content-Encoding: gzip 11 TxHeader c Content-Type: text/html; charset=UTF-8 11 TxHeader c Content-Length: 7682 11 TxHeader c Accept-Ranges: bytes 11 TxHeader c Date: Thu, 13 Mar 2014 12:08:38 GMT 11 TxHeader c X-Varnish: 1420058564 11 TxHeader c Age: 0 11 TxHeader c Via: 1.1 varnish 11 TxHeader c Connection: keep-alive 11 Length c 7682 11 ReqEnd c 1420058564 1394712517.488089323 1394712518.017520905 0.000098944 0.529357433 0.000074148 0 CLI - Rd ping 0 CLI - Wr 200 19 PONG 1394712518 1.0 0 CLI - Rd ping 0 CLI - Wr 200 19 PONG 1394712521 1.0
要确定响应是否可caching,请将以下内容添加到您的VCL中,并在更改后使用varnishlog输出更新您的问题。 另外请张贴您的清漆命令行,特别是默认的TTL( -t参数)。 由于后端服务器未发送Cache-Control标头,而且您没有在vcl_fetch定义beresp.ttl , vcl_fetch Varnish将使用使用-t开关定义的TTL的默认值。
以下VCL将为每个请求添加X-Cacheable和X-ttl头文件。
sub vcl_fetch { # Varnish determined the object was not cacheable if (!(beresp.ttl > 0s)) { set beresp.http.X-Cacheable = "NO:Not Cacheable, ttl <0s"; set beresp.http.X-ttl = beresp.ttl; return(hit_for_pass); } elseif (req.http.Cookie) { set beresp.http.X-Cacheable = "NO:Got cookie"; set beresp.http.X-Cookie = req.http.Cookie; return(hit_for_pass); } elseif (beresp.http.Cache-Control ~ "private") { set beresp.http.X-Cacheable = "NO:Cache-Control=private"; return(hit_for_pass); } elseif (beresp.http.Cache-Control ~ "no-cache" || beresp.http.Pragma ~ "no-cache") { set beresp.http.X-Cacheable = "Refetch forced by user"; return(hit_for_pass); # You are extending the lifetime of the object artificially } elseif (beresp.ttl < 1s) { set beresp.ttl = 5s; set beresp.grace = 5s; set beresp.http.X-Cacheable = "YES:FORCED"; # Varnish determined the object was cacheable } else { set beresp.http.X-Cacheable = "YES"; set beresp.http.X-ttl = beresp.ttl; } }