2012-02-28 3 views

답변

3

크롬에 세션 쿠키가있어 다른 요청이 백엔드로 전달되는 경우가 있습니다.

+0

예. 요청한 쿠키를 확인합니다. 그들은 다르다. 첫 번째 방문으로 인해 발생했습니다. 응답으로 Chrome 클라이언트에 새로운 쿠키가 설정되었습니다. – Hao

+0

쿠키는 일반적으로 해시에 쿠키를 추가하지 않는 한 캐싱을 중단합니다. [https://www.varnish-cache.org/trac/wiki/VCLExampleCacheCookies](https://www.varnish-cache.org/trac/wiki/VCLExampleCacheCookies) –

1

가장 일반적인 원인은 Accept-Encoding 헤더의 정규화입니다. Firefox와 Chrome은 모두 다른 것으로 보냅니다.() 귀하의 하위 vcl_recv이 추가 :

if (req.http.Accept-Encoding) { 
    if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") { 
     # No point in compressing these 
     remove req.http.Accept-Encoding; 
    } elsif (req.http.Accept-Encoding ~ "gzip") { 
     set req.http.Accept-Encoding = "gzip"; 
    } elsif (req.http.Accept-Encoding ~ "deflate") { 
     set req.http.Accept-Encoding = "deflate"; 
    } else { 
     # unkown algorithm 
     remove req.http.Accept-Encoding; 
    } 
} 

이것은 또한 Varnish manual on the "Vary" header에 설명되어 있습니다.

+0

그래도 크롬은 캐싱하지 않습니다 – Hao

+0

vcl_hash는 어떻게 생겼습니까? varnishlog에 'Vary : User-Agent'와 같은 헤더가 있습니까? 그렇다면 바니시가 User-Agent마다 다른 캐시를 유지하도록 지시합니다 (OS 문자열 등을 포함하기 때문에 거의 고유합니다) – Mojah

0
if (req.http.Accept-Encoding) { 
     if (req.http.Accept-Encoding ~ "gzip") { 
      set req.http.Accept-Encoding = "gzip"; 
     } elsif (req.http.Accept-Encoding ~ "deflate") { 
      set req.http.Accept-Encoding = "deflate"; 
     } else { 
      # unknown language. Remove the accept-language header and 
      # use the backend default. 
      unset req.http.Accept-Encoding; 
     } 
    } 
    //add below condition along with above code in vcl_recv subroutine. 
    if(req.http.User-Agent) { 
     unset req.http.User-Agent; 
    } 
+0

다른 현명한 vcl_deliver 하위 코드를 작성할 수 있습니다. 응답 헤더에서 Vary를 설정 해제하는 루틴. unset resp.http.Vary; –

관련 문제