Cache
Varnish 不會清除我由 Plone 發送的請求
我已經啟動並執行了 varnish 3.0.5,連接到 Plone 4 後端。我的請求被記憶體,但不能可靠地清除,實際上只有在 ttl 到期後。plone.app.caching 是外掛,每次修改對象時都會發送清除請求。這是清漆日誌:
14 BackendOpen b backend_0 127.0.0.1 54428 127.0.0.1 9088 14 BackendXID b 1585950387 14 TxRequest b PURGE 14 TxURL b /VirtualHostBase/https/example.com/path/VirtualHostRoot/pic/a.jpg 14 TxProtocol b HTTP/1.1 14 TxHeader b Host: localhost:9081 14 TxHeader b X-Varnish: 1585950387 14 BackendClose b backend_0 13 ReqStart c 127.0.0.1 56614 1585950387 13 RxRequest c PURGE 13 RxURL c /VirtualHostBase/https/example.com/path/VirtualHostRoot/pic/a.jpg 13 RxProtocol c HTTP/1.1 13 RxHeader c Host: localhost:9081 13 VCL_call c recv pipe 13 VCL_call c hash 13 Hash c /VirtualHostBase/https/example.com/path/VirtualHostRoot/pic/a.jpg 13 VCL_return c hash 13 VCL_call c pipe pipe 13 Backend c 14 backend_0 backend_0 13 ReqEnd c 1585950387 1412603444.714001656 1412603505.824758053 0.000071526 0.000180483 61.110575914
在 default.vcl 我已經配置了 acl purgers、基本的 vcl_hit 和 vcl_miss 函式,在 vcl_recv 裡面我有:
if (req.request == "PURGE") { if (!client.ip ~ purge) { error 405 "This IP is not allowed to send purge requests."; } return (lookup); }
清除後打開圖像時,我仍然得到舊版本,直到 max age 過期。這是縮短的日誌輸出:
3 RxURL c /VirtualHostBase/https/example.com:443/path/VirtualHostRoot/pic/a.jpg 3 RxProtocol c HTTP/1.0 3 RxHeader c Host: enertour.bz.it 3 VCL_call c recv lookup 3 VCL_call c hash 3 Hash c /VirtualHostBase/https/example.com/path/VirtualHostRoot/pic/a.jpg 3 VCL_return c hash 3 Hit c 1585950403 3 VCL_call c hit deliver 3 VCL_call c deliver deliver 3 TxHeader c Cache-Control: max-age=0, s-maxage=240, must-revalidate 3 TxHeader c X-Cache-Rule: plone.content.file 3 TxHeader c Age: 181
到目前為止,我所做的是重寫請求的雜湊值,以匹配清除請求的雜湊。它們是相同的,但我的對像沒有被清除,我不知道為什麼?是因為請求的主機發生了變化嗎?
很高興任何提示!
今天再次查看我的 vcl,我發現在修改過程中,清除功能滑到了我檢查請求類型的行下。因此不允許清洗,它在管道中完成。正確的順序是:
if (req.request == PURGE) { ... return (lookup); } if (req.request != "(GET|HEAD)" { ... return (pass); }