Estou tentando usar o cache de verniz para armazenar em cache uma página do mediawiki para usuários logados. Eu uso o Ubuntu 14.04, verniz 4.0.3 (porta 80) e nginx como um servidor web (porta 8080). Como vcl eu copiei a configuração de mediawiki.org e com a minha limitada compreensão do vcl do verniz não consigo encontrar um problema.
Agora eu tenho o problema, que as páginas do mediawiki não são armazenadas em cache (elas são entregues através de verniz, mas não armazenadas em cache. A idade é sempre 0 e apenas um id de solicitação do X-Varnish). arquivo (test.php), que está na raiz da minha página da web (ou seja, example.com/test.php
) e verificado, se é armazenado corretamente, mas não é.Eu vejo os mesmos cabeçalhos, e às vezes o controle de cache com max -age = 0. O arquivo test.php tem o seguinte conteúdo:
<?php
echo 'Hello world';
Agora, não tenho ideia de onde está o problema, pesquisei sozinho, mas não consegui encontrar nenhuma thread, em que pelo menos uma página de teste estática e não funcional não está armazenada corretamente. Alguém pode me ajudar?
Aqui os cabeçalhos para o primeiro pedido (eu substituí o ip e o domínio pelos exemplos:)):
Cabeçalhos de solicitações
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:no-cache
Connection:keep-alive
Host:example.com
Pragma:no-cache
User-Agent:Mozilla/5.0 (Linux; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Safari/537.36
Remote Address:0.0.0.0:80
Request URL:http://example.com/test.php
Request Method:GET
Status Code:200 OK
Cabeçalhos de resposta
Accept-Ranges:bytes
Age:0
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html
Date:Sun, 10 May 2015 20:05:05 GMT
Server:nginx/1.4.6 (Ubuntu)
Transfer-Encoding:chunked
Via:1.1 varnish-v4
X-Powered-By:HHVM/3.7.0
X-Varnish:2
E os cabeçalhos da segunda solicitação:
Cabeçalhos de solicitações
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:max-age=0
Connection:keep-alive
Host:example.com
User-Agent:Mozilla/5.0 (Linux; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Safari/537.36
Remote Address:0.0.0.0:80
Request URL:http://example.com/test.php
Request Method:GET
Cabeçalhos de resposta
Status Code:200 OK
Accept-Ranges:bytes
Age:0
Connection:keep-alive
Content-Encoding:gzip
Content-Length:24
Content-Type:text/html
Date:Sun, 10 May 2015 20:07:49 GMT
Server:nginx/1.4.6 (Ubuntu)
Via:1.1 varnish-v4
X-Powered-By:HHVM/3.7.0
X-Varnish:5
Apenas para completar aqui a configuração do nginx para este site:
server {
# Running port
listen 8080;
server_name example.com;
# Root directory
root /data/www/example.com/main;
index index.php;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
client_max_body_size 5m;
client_body_timeout 60;
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?title=$1&$args;
}
location ^~ /maintenance/ {
return 403;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
try_files $uri /index.php;
expires max;
log_not_found off;
}
location = /_.gif {
expires max;
empty_gif;
}
location ^~ /cache/ {
deny all;
}
location /dumps {
root /data/www/example.com/local;
autoindex on;
}
}
EDIT: cabeçalhos de resposta com curl:
HTTP/1.1 200 OK
Server: nginx/1.4.6 (Ubuntu)
Date: Sun, 10 May 2015 20:42:01 GMT
Content-Type: text/html
X-Powered-By: HHVM/3.7.0
Vary: Accept-Encoding
X-Varnish: 17
Age: 0
Via: 1.1 varnish-v4
Content-Length: 4
Connection: keep-alive
Accept-Ranges: bytes
EDIT2: E o vernizlog dessa solicitação:
* << BeReq >> 53
- Begin bereq 52 pass
- Timestamp Start: 1431291731.991895 0.000000 0.000000
- BereqMethod GET
- BereqURL /test.php
- BereqProtocol HTTP/1.1
- BereqHeader User-Agent: curl/7.35.0
- BereqHeader Host: example.com
- BereqHeader Accept: */*
- BereqHeader X-Forwarded-For: 0.0.0.1
- BereqHeader X-Varnish: 53
- VCL_call BACKEND_FETCH
- VCL_return fetch
- Backend 17 default default(127.0.0.1,,8080)
- Timestamp Bereq: 1431291731.991930 0.000035 0.000035
- Timestamp Beresp: 1431291731.992944 0.001049 0.001014
- BerespProtocol HTTP/1.1
- BerespStatus 200
- BerespReason OK
- BerespHeader Server: nginx/1.4.6 (Ubuntu)
- BerespHeader Date: Sun, 10 May 2015 21:02:11 GMT
- BerespHeader Content-Type: text/html
- BerespHeader Transfer-Encoding: chunked
- BerespHeader Connection: keep-alive
- BerespHeader X-Powered-By: HHVM/3.7.0
- BerespHeader Vary: Accept-Encoding
- TTL RFC 120 -1 -1 1431291732 1431291732 1431291731 0 0
- VCL_call BACKEND_RESPONSE
- TTL VCL -1 120 0 1431291732
- VCL_return deliver
- Storage malloc Transient
- ObjProtocol HTTP/1.1
- ObjStatus 200
- ObjReason OK
- ObjHeader Server: nginx/1.4.6 (Ubuntu)
- ObjHeader Date: Sun, 10 May 2015 21:02:11 GMT
- ObjHeader Content-Type: text/html
- ObjHeader X-Powered-By: HHVM/3.7.0
- ObjHeader Vary: Accept-Encoding
- Fetch_Body 2 chunked stream
- BackendReuse 17 default(127.0.0.1,,8080)
- Timestamp BerespBody: 1431291731.993028 0.001132 0.000083
- Length 4
- BereqAcct 129 0 129 212 13 225
- End
* << Request >> 52
- Begin req 51 rxreq
- Timestamp Start: 1431291731.991840 0.000000 0.000000
- Timestamp Req: 1431291731.991840 0.000000 0.000000
- ReqStart 79.193.10.211 52555
- ReqMethod GET
- ReqURL /test.php
- ReqProtocol HTTP/1.1
- ReqHeader User-Agent: curl/7.35.0
- ReqHeader Host: example.com
- ReqHeader Accept: */*
- ReqHeader X-Forwarded-For: 0.0.0.1
- VCL_call RECV
- ReqUnset X-Forwarded-For: 0.0.0.1
- ReqHeader X-Forwarded-For: 0.0.0.1
- VCL_return hash
- VCL_call HASH
- VCL_return lookup
- Debug "XXXX HIT-FOR-PASS"
- HitPass 2147516455
- VCL_call PASS
- VCL_return fetch
- Link bereq 53 pass
- Timestamp Fetch: 1431291731.993038 0.001199 0.001199
- RespProtocol HTTP/1.1
- RespStatus 200
- RespReason OK
- RespHeader Server: nginx/1.4.6 (Ubuntu)
- RespHeader Date: Sun, 10 May 2015 21:02:11 GMT
- RespHeader Content-Type: text/html
- RespHeader X-Powered-By: HHVM/3.7.0
- RespHeader Vary: Accept-Encoding
- RespHeader X-Varnish: 52
- RespHeader Age: 0
- RespHeader Via: 1.1 varnish-v4
- VCL_call DELIVER
- VCL_return deliver
- Timestamp Process: 1431291731.993080 0.001240 0.000041
- RespHeader Content-Length: 4
- Debug "RES_MODE 2"
- RespHeader Connection: keep-alive
- RespHeader Accept-Ranges: bytes
- Timestamp Resp: 1431291731.993190 0.001350 0.000110
- Debug "XXX REF 1"
- ReqAcct 82 0 82 269 4 273
- End
* << Session >> 51
- Begin sess 0 HTTP/1
- SessOpen 0.0.0.1 52555 :80 0.0.0.1 80 1431291731.989801 14
- Link req 52 rxreq
- SessClose REM_CLOSE 0.037
- End
EDIT3: cabeçalhos para duas solicitações após uma nova configuração deliver
:
florian@florian-VirtualBox:/var/www/html/w$ curl -v http://example.com/test.php
* Hostname was NOT found in DNS cache
* Trying 0.0.0.0...
* Connected to example.com (0.0.0.0) port 80 (#0)
> GET /test.php HTTP/1.1
> User-Agent: curl/7.35.0
> Host: example.com
> Accept: */*
>
< HTTP/1.1 200 OK
* Server nginx/1.4.6 (Ubuntu) is not blacklisted
< Server: nginx/1.4.6 (Ubuntu)
< Date: Sun, 10 May 2015 21:32:52 GMT
< Content-Type: text/html
< X-Powered-By: HHVM/3.7.0
< X-Varnish: 2
< Age: 0
< Via: 1.1 varnish-v4
< X-MISC: MIS
< Transfer-Encoding: chunked
< Connection: keep-alive
< Accept-Ranges: bytes
florian@florian-VirtualBox:/var/www/html/w$ curl -v http://example.com/test.php
* Hostname was NOT found in DNS cache
* Trying 0.0.0.0...
* Connected to dexample.com (0.0.0.0) port 80 (#0)
> GET /test.php HTTP/1.1
> User-Agent: curl/7.35.0
> Host: example.com
> Accept: */*
>
< HTTP/1.1 200 OK
* Server nginx/1.4.6 (Ubuntu) is not blacklisted
< Server: nginx/1.4.6 (Ubuntu)
< Date: Sun, 10 May 2015 21:32:53 GMT
< Content-Type: text/html
< X-Powered-By: HHVM/3.7.0
< Vary: Accept-Encoding
< X-Varnish: 32770
< Age: 0
< Via: 1.1 varnish-v4
< X-MISC: MIS
< Content-Length: 4
< Connection: keep-alive
< Accept-Ranges: bytes
EDITX: Agora trabalhando para o primeiro pedido, mas todos os pedidos seguintes são entregues pelo backend, aqui os cabeçalhos: / Parece falso, esse verniz envia um cabeçalho de controle de cache max-age = 0?
Primeiro pedido:
Solicitar cabeçalhos
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Host:example.com
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36
Cabeçalhos de resposta
Accept-Ranges:bytes
Age:32
Cache-Control:s-maxage=18000, must-revalidate, max-age=0
Connection:keep-alive
Content-Encoding:gzip
Content-language:de
Content-Length:12102
Content-Type:text/html; charset=UTF-8
Date:Sun, 10 May 2015 22:33:34 GMT
Last-Modified:Sun, 10 May 2015 17:33:34 GMT
Server:nginx/1.4.6 (Ubuntu)
Vary:Accept-Encoding, Cookie
Via:1.1 varnish-v4
X-Content-Type-Options:nosniff
X-Powered-By:HHVM/3.7.0
X-UA-Compatible:IE=Edge
X-Varnish:131094 32817
Segundo pedido:
Solicitar cabeçalhos
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:max-age=0
Connection:keep-alive
Cookie:centralnotice_bucket=0-4.2; __atuvc=1%7C19; __atuvs=554fdce151aee950000; mediaWiki.user.bucket%3Aext.articleFeedback-tracking=0%3Aignore; clicktracking-session=gCQO3Eyuh6ZzPCP0q9mTliq4RNSPD1u2O
Host:example.com
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36
Cabeçalhos de resposta
Accept-Ranges:bytes
Age:0
Cache-Control:s-maxage=18000, must-revalidate, max-age=0
Connection:keep-alive
Content-Encoding:gzip
Content-language:de
Content-Type:text/html; charset=UTF-8
Date:Sun, 10 May 2015 22:37:48 GMT
Last-Modified:Sun, 10 May 2015 17:37:48 GMT
Server:nginx/1.4.6 (Ubuntu)
Transfer-Encoding:chunked
Vary:Accept-Encoding, Cookie
Via:1.1 varnish-v4
X-Content-Type-Options:nosniff
X-Powered-By:HHVM/3.7.0
X-UA-Compatible:IE=Edge
X-Varnish:65630