Varnish
Varnish 通過呼叫“hit_for_pass”拒絕記憶體
13 StatSess c 127.0.0.2 48714 0 1 1 0 1 1 687 2573 24 BackendXID b 1374630903 24 TxRequest b GET 24 TxURL b /do_ajax.php?action=get-dom 24 TxProtocol b HTTP/1.0 24 TxHeader b X-Forwarded-Proto: https 24 TxHeader b X-Forwarded-Port: 443 24 TxHeader b Host: www.officestocks.com 24 TxHeader b Accept-Language: en-US,en;q=0.9 24 TxHeader b Accept: text/plain, */*; q=0.01 24 TxHeader b User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 15_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Mobile/15E148 Safari/604.1 24 TxHeader b Referer: https://www.officestocks.com/ 24 TxHeader b X-Requested-With: XMLHttpRequest 24 TxHeader b X-Remote-IP: 184.89.213.63 24 TxHeader b X-Forwarded-For: 184.89.213.63 24 TxHeader b Accept-Encoding: gzip 24 TxHeader b X-Varnish: 1374630903 24 RxProtocol b HTTP/1.1 24 RxStatus b 200 24 RxResponse b OK 24 RxHeader b Date: Fri, 04 Mar 2022 20:20:57 GMT 24 RxHeader b Server: Apache/2.2.15 (CentOS) 24 RxHeader b X-Robots-Tag: noindex 24 RxHeader b X-Content-Type-Options: nosniff 24 RxHeader b Expires: Wed, 11 Jan 1984 05:00:00 GMT 24 RxHeader b Cache-Control: no-cache, must-revalidate, max-age=0 24 RxHeader b X-Frame-Options: SAMEORIGIN 24 RxHeader b Referrer-Policy: strict-origin-when-cross-origin 24 RxHeader b Vary: Accept-Encoding,User-Agent 24 RxHeader b Content-Encoding: gzip 24 RxHeader b Connection: close 24 RxHeader b Content-Type: text/html; charset=UTF-8 24 Fetch_Body b 5(eof) cls 0 mklen 1 24 Length b 26 24 BackendClose b default 12 SessionOpen c 127.0.0.2 48702 127.0.0.2:80 12 ReqStart c 127.0.0.2 48702 1374630903 12 RxRequest c GET 12 RxURL c /do_ajax.php?action=get-dom 12 RxProtocol c HTTP/1.0 12 RxHeader c X-Real-IP: 184.89.213.63 12 RxHeader c X-Forwarded-For: 184.89.213.63 12 RxHeader c X-Forwarded-Proto: https 12 RxHeader c X-Forwarded-Port: 443 12 RxHeader c Host: www.officestocks.com 12 RxHeader c Connection: close 12 RxHeader c Accept-Language: en-US,en;q=0.9 12 RxHeader c Accept-Encoding: gzip, deflate, br 12 RxHeader c Accept: text/plain, */*; q=0.01 12 RxHeader c User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 15_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Mobile/15E148 Safari/604.1 12 RxHeader c Referer: https://www.officestocks.com/ 12 RxHeader c Cache-Control: max-age=1000 12 RxHeader c X-Requested-With: XMLHttpRequest 12 VCL_call c recv 12 VCL_acl c MATCH proxyIps 127.0.0.2 12 VCL_return c lookup 12 VCL_call c hash 12 Hash c /do_ajax.php?action=get-dom 12 Hash c www.officestocks.com 12 Hash c 443 12 Hash c 12 VCL_return c hash 12 HitPass c 1374630098 12 VCL_call c pass pass 12 Backend c 24 default default 12 TTL c 1374630903 RFC 0 -1 -1 1646425258 0 1646425257 442645200 0 12 VCL_call c fetch 12 TTL c 1374630903 VCL -0 120 -1 1646425258 -1 12 TTL c 1374630903 VCL 121 120 -1 1646425258 -1 12 VCL_return c hit_for_pass 12 ObjProtocol c HTTP/1.1 12 ObjResponse c OK 12 ObjHeader c Date: Fri, 04 Mar 2022 20:20:57 GMT 12 ObjHeader c Server: Apache/2.2.15 (CentOS) 12 ObjHeader c X-Robots-Tag: noindex 12 ObjHeader c X-Content-Type-Options: nosniff 12 ObjHeader c Expires: Wed, 11 Jan 1984 05:00:00 GMT 12 ObjHeader c Cache-Control: no-cache, must-revalidate, max-age=0 12 ObjHeader c X-Frame-Options: SAMEORIGIN 12 ObjHeader c Referrer-Policy: strict-origin-when-cross-origin 12 ObjHeader c Content-Encoding: gzip 12 ObjHeader c Content-Type: text/html; charset=UTF-8 12 Gzip c u F - 26 0 80 128 138 12 VCL_call c deliver deliver 12 TxProtocol c HTTP/1.1 12 TxStatus c 200 12 TxResponse c OK 12 TxHeader c Server: Apache/2.2.15 (CentOS) 12 TxHeader c X-Robots-Tag: noindex 12 TxHeader c X-Content-Type-Options: nosniff 12 TxHeader c Expires: Wed, 11 Jan 1984 05:00:00 GMT 12 TxHeader c Cache-Control: no-cache, must-revalidate, max-age=0 12 TxHeader c X-Frame-Options: SAMEORIGIN 12 TxHeader c Referrer-Policy: strict-origin-when-cross-origin 12 TxHeader c Content-Encoding: gzip 12 TxHeader c Content-Type: text/html; charset=UTF-8 12 TxHeader c Content-Length: 26 12 TxHeader c Accept-Ranges: bytes 12 TxHeader c Date: Fri, 04 Mar 2022 20:20:58 GMT 12 TxHeader c X-Varnish: 1374630903 12 TxHeader c Via: 1.1 varnish 12 TxHeader c Connection: close 12 TxHeader c X-Age: 0 12 TxHeader c X-Cache: MISS 12 TxHeader c X-Pragma: 12 TxHeader c X-Cache-Control: 12 TxHeader c X-Stock: 12 TxHeader c X-URL: /do_ajax.php?action=get-dom 12 TxHeader c X-Auth: 12 TxHeader c X-IP: 12 Length c 26 12 ReqEnd c 1374630903 1646425257.592263222 1646425258.176410437 0.000068903 0.584094763 0.000052452 12 SessionClose c Connection: close
因此,我在調試時發現 varnish 正在執行記憶體查找,但結果是返回了一個 hit-for-pass 對象。但是在這裡閱讀了一些關於它的資訊後: https ://stackoverflow.com/questions/12691489/varnish-hit-for-pass-means如果我理解正確,我看到它沒有記憶體由於高流量,有沒有辦法強制清漆記憶體對象?
我看到這樣的事情,但我不知道如何在我的清漆配置中覆蓋它:
12 TxHeader c Expires: Wed, 11 Jan 1984 05:00:00 GMT
剛剛看到這個,但它並沒有幫助我確定問題可能是什麼:
https://stackoverflow.com/questions/35449723/varnish-what-is-causing-hit-for-pass
您的後端返回一個
Cache-Control: no-cache, must-revalidate, max-age=0
明確告訴 Varnish 不要記憶體的標頭。我最初的建議是確保
/do_ajax.php?action=get-dom
資源返回一個Cache-Control
允許記憶體的標頭。如果這是不可能的,你總是可以使用下面的 VCL 程式碼來強制記憶體:
sub vcl_backend_response { if(bereq.url == "/do_ajax.php?action=get-dom") { unset beresp.http.Expires; set beresp.http.Cache-control = "public, max-age=3600"; set beresp.ttl = 1h; return(deliver); } }
**重要提示:**根據您的
varnishlog
命令輸出,我可以看到您使用的是過時版本的 Varnish。你能確保你在 Varnish 6 或 7 上嗎?有關下載和安裝說明,請參閱https://www.varnish-software.com/developers/downloads/。