2014-01-10 4 views
1

은 내가Nginx의 캐시 및 YII

set $no_cache 0; 
    if ($request_method = POST) 
    { 
     set $no_cache 1; 
    } 
    #Don't cache if the URL contains a query string 
    if ($query_string != "") 
    { 
     set $no_cache 1; 
    } 
    #Don't cache the following URLs 
    if ($request_uri ~* "/(api/|login|logout|corporate/login|corporate/logout)") 
    { 
     set $no_cache 1; 
    } 
    #Don't cache if there is a cookie called PHPSESSID 
    if ($http_cookie = "PHPSESSID") 
    { 
     set $no_cache 1; 
    } 
location ~ \.php$ { 
     fastcgi_cache_bypass $no_cache; 
     fastcgi_no_cache $no_cache; 
     fastcgi_pass php-fpm; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME /srv/www/site/index.php; 
     include fastcgi_params; 
     try_files $fastcgi_script_name =404; 
     fastcgi_cache nginx_webpy_cache; 
     fastcgi_cache_valid 200 301 302 304 2m; 
     fastcgi_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$host|$request_uri|$cookie_login_id"; 
     fastcgi_ignore_headers Cache-Control Expires Set-Cookie; 
     fastcgi_hide_header "Set-Cookie"; 
    } 

location ~* \.(ico|js|txt|jpg|jpeg|png|css|pdf)$ { 
     root /srv/www/site; 
     access_log off; 
     expires 1h; 
     add_header Pragma public; 
     add_header Cache-Control "public"; 
    } 

가 대부분 확인 작업 서버 섹션에서 HTTP 섹션

fastcgi_cache_path /var/cache/nginx/ levels=1:2 keys_zone=nginx_webpy_cache:1m inactive=1d; 
fastcgi_temp_path /var/cache/nginx/temp; 

에 nginx를 캐싱 을 만들어 내 Nginx에 + PHP-FPM 에 대한 구성을 가지고,하지만 난 로그 아웃 할 수 없으며 로그 아웃하고 여전히 로그인 사용자를 어떻게 생각합니까?

답변

0

대부분의 경우 서버 HTTP 캐시를 사용하여 인증하는 페이지를 실제로 캐시 할 수 없습니다. 사용자는 자신의 프로필에 액세스하는 동안 (예 : URL이 정말로 다른 경우가 아니라면 일반적으로 모범 사례가 아닙니다) 다른 사람의 페이지를 단순히 보게됩니다.

해결 방법은 조각 캐싱을 사용하는 것입니다. Yii 관련 자습서는 here을 참조하십시오.