2012-02-18 4 views
1

私は、このコマンドを実行した場合ワニス:Cachebleが、要求は「cacheble」でなく、「キャッシュされた」という

varnishtop -i txurl 

をキャッシュされていません。私は "年齢= 0"(ニスに保たれている年齢)、それを編集する方法を参照してください?

これは私の.phpページのリクエスト

は古本http://example.com

User-Agent: lwp-request/5.810 

200 OK 
Cache-Control: max-age=60, public, must-revalidate 
Connection: close 
Date: Sat, 18 Feb 2012 12:14:33 GMT 
Via: 1.1 varnish 
Age: 0 
Server: Apache 
Vary: Accept-Encoding 
Content-Type: text/html 
Expires: Sat, 18 Feb 2012 12:24:33 GMT 
Client-Date: Sat, 18 Feb 2012 12:14:34 GMT 
Client-Peer: 173.236.219.104:80 
Client-Response-Num: 1 
Client-Transfer-Encoding: chunked 
X-Cache: MISS 
X-Cacheable: YES 
X-Varnish: 840966561 

の.htaccessコード

# BEGIN Expire headers 
<ifModule mod_expires.c> 
    ExpiresActive On 
    ExpiresDefault "access plus 5 seconds" 
    ExpiresByType image/x-icon "access plus 2592000 seconds" 
    ExpiresByType image/jpeg "access plus 2592000 seconds" 
    ExpiresByType image/png "access plus 2592000 seconds" 
    ExpiresByType image/gif "access plus 2592000 seconds" 
    ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds" 
    ExpiresByType text/css "access plus 604800 seconds" 
    ExpiresByType text/javascript "access plus 216000 seconds" 
    ExpiresByType application/javascript "access plus 216000 seconds" 
    ExpiresByType application/x-javascript "access plus 216000 seconds" 
    ExpiresByType text/html "access plus 600 seconds" 
    ExpiresByType application/xhtml+xml "access plus 600 seconds" 
</ifModule> 
# END Expire headers 

# BEGIN Cache-Control Headers 
<ifModule mod_headers.c> 
    <filesMatch "\.(ico|jpe?g|png|gif|swf)$"> 
    Header set Cache-Control "public" 
    </filesMatch> 
    <filesMatch "\.(css)$"> 
    Header set Cache-Control "public" 
    </filesMatch> 
    <filesMatch "\.(js)$"> 
    Header set Cache-Control "private" 
    </filesMatch> 
    <filesMatch "\.(x?html?|php)$"> 
    Header set Cache-Control "public, must-revalidate" 
    </filesMatch> 
</ifModule> 

をGET

Default.vlcです
backend default { 
    .host = "173.236.219.104"; 
    .port = "81"; 
    .connect_timeout = 600s; 
    .first_byte_timeout = 600s; 
    .between_bytes_timeout = 600s; 
} 

sub vcl_deliver { 
     if (obj.hits > 0) { 
       set resp.http.X-Cache = "HIT"; 
     } else { 
       set resp.http.X-Cache = "MISS"; 
     } 
} 

sub vcl_fetch { 

    # Varnish determined the object was not cacheable 
    if (beresp.ttl <= 0s) { 
     set beresp.http.X-Cacheable = "NO:Not Cacheable"; 

    # You don't wish to cache content for logged in users 
    } elsif (req.http.Cookie ~ "(UserID|_session)") { 
     set beresp.http.X-Cacheable = "NO:Got Session"; 
     return(hit_for_pass); 

    # You are respecting the Cache-Control=private header from the backend 
    } elsif (beresp.http.Cache-Control ~ "private") { 
     set beresp.http.X-Cacheable = "NO:Cache-Control=private"; 
     return(hit_for_pass); 

    # Varnish determined the object was cacheable 
    } else { 
     set beresp.http.X-Cacheable = "YES"; 
    } 

    # .... 

    return(deliver); 
} 
+0

ワニスの設定も追加できますか?関連する部分のみ。これはワニスの設定問題のように聞こえるからです。 – Silenteh

+0

OK、完了。更新された投稿 – sparkle

+0

varnishlogを実行してからGET -Used http://example.comまたはcurl -I http://example.com/を実行して、ここにvarnishlogの出力を貼り付けてください。 –

答えて

5

ほとんどの場合、バックエンドはCookieを返すため、ワニスはコンテンツをキャッシュしません。それについて

詳細:Varnish-Cookies

はまた、あなたがLWPから取得応答にいくつかの矛盾があります。 実際には、max-ageヘッダーは60秒に設定されていますが、バックエンドでは設定されていません。

原点へのLWP要求も問題のデバッグに役立ちます。

関連する問題