나는 Varnish 3.0.3을 사용 중이며 정적 리소스에 대한 HTTP 헤더의 최대 수명을 설정하여 브라우저 캐싱을 활용합니다. 나는 다음과 같은 구성이 default.vcl에 추가 시도 :Varnish 3 - HTTP 헤더의 최대 수명 설정 방법
sub vcl_fetch {
if (beresp.cacheable) {
/* Remove Expires from backend, it's not long enough */
unset beresp.http.expires;
/* Set the clients TTL on this object */
set beresp.http.cache-control = "max-age=900";
/* Set how long Varnish will keep it */
set beresp.ttl = 1w;
/* marker for vcl_deliver to reset Age: */
set beresp.http.magicmarker = "1";
}
}
sub vcl_deliver {
if (resp.http.magicmarker) {
/* Remove the magic marker */
unset resp.http.magicmarker;
/* By definition we have a fresh object */
set resp.http.age = "0";
}
}
이는 https://www.varnish-cache.org/trac/wiki/VCLExampleLongerCaching에서 복사됩니다. 어쩌면 내가 오타를 만들었을 수도 있습니다. Varnish를 다시 시작하면 더 이상 작동하지 않습니다.
두 가지 질문이 있습니다. 이것이 Varnish 3의 올바른 방법입니까? 그렇다면, 내가 뭘 잘못하고 있니? 둘째, 다시 시작하기 전에 Varnish 구성 파일을 테스트하는 방법이 있습니까? 아파치가 "/ sbin/service httpd configtest"와 함께 가지는 방식에 따른 것. 그것은 실수하기 전에 잡는다. 고맙습니다.