我使用Wordpress 3.8.1
和Varnish 3.0.5
。由於VCL的噩夢,我確定Varnish不會緩存。而且我也不知道Wordpress的標準/正確VCL在哪裏。Wordpress Varnish年齡= 0還是不緩存(Cookies?)
我的WordPress的是多站點,我把清漆放在框的頂部,Wordpress虛擬機本身。 Varnish @ 8080
和Apache @ 80/443
。
,因爲我不知道什麼VCL,我只是用一個隨機的VCL,我發現:
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 60s;
.first_byte_timeout = 60s;
.between_bytes_timeout = 60s;
}
sub vcl_recv {
if (req.restarts == 0) {
if (req.http.x-forwarded-for) {
set req.http.X-Forwarded-For =
req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
if (req.request == "PURGE") {
if (client.ip != "xx.xx.xx.xx") {
error 405 "Not allowed.";
}
return (lookup);
}
if (req.request != "GET" &&
req.request != "HEAD" &&
req.request != "PUT" &&
req.request != "POST" &&
req.request != "TRACE" &&
req.request != "OPTIONS" &&
req.request != "DELETE") {
return (pipe);
}
if (req.request != "GET" && req.request != "HEAD") {
return (pass);
}
if (!(req.url ~ "wp-(login|admin)") &&
!(req.url ~ "&preview=true")) {
unset req.http.cookie;
}
if (req.http.Authorization || req.http.Cookie) {
return (pass);
}
return (lookup);
}
sub vcl_hit {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
return (deliver);
}
sub vcl_miss {
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
return (fetch);
}
sub vcl_fetch {
if (!(req.url ~ "wp-(login|admin)")) {
unset beresp.http.set-cookie;
set beresp.ttl = 96h;
}
if (beresp.ttl <= 0s ||
beresp.http.Set-Cookie ||
beresp.http.Vary == "*") {
set beresp.ttl = 120 s;
return (hit_for_pass);
}
return (deliver);
}
(我用我的IP地址爲 'XX.XX.XX.XX')
但無論如何,這不是通過總是得到age : 0
。我知道VCL必須處理Wordpress COOKIES和其他COOKIES,比如G.A等。
如何做,或者我可以在哪裏找到適用於Wordpress的標準/正確的VCL?
你裏面'vcl_recv'正確的功能,但我不知道,如果別的東西衝突與它,但你真的應該刪除所有默認的東西,它已經由清漆它的自我執行。 –
這裏同樣的問題。內容全部被緩存,例如圖像和css文件,但主頁面本身始終在標題中聲明「年齡:0」。有些事情是錯的。 – CaptSaltyJack