Re: fastcgi_cache не кеширует ответ

Maxim Dounin mdounin на mdounin.ru
Пт Фев 18 15:33:29 MSK 2011


Hello!

On Fri, Feb 18, 2011 at 09:28:08AM +0200, Andrew Sitnikov wrote:

>  кусок конфига
> 
>  location  /js {
>      access_log off;
>
>      fastcgi_cache cache;
>
>      fastcgi_cache_valid 200 302 10m;
>      fastcgi_cache_valid 404 1m;
>      fastcgi_cache_key $request_uri;
>      fastcgi_cache_use_stale updating;
>
>      fastcgi_pass 127.0.0.1:9000;
>
>      include "/etc/nginx/params.d/fastcgi_params.conf";
>      fastcgi_param SCRIPT_FILENAME $document_root/index.php;
>      fastcgi_param SCRIPT_NAME /index.php;
>
>      fastcgi_hide_header X-Powered-By;
>
>      add_header  X-Nginx-Cache  "yes,js";
>  }
> 
>  в аттаче - debug log (2262)
> 
>  рядом точно такая же конфигурация /htmlbanner {} и там кешируется, лог 2965

...
2011/02/18 09:15:17 [debug] 19656#0: *2262 http fastcgi header: "Set-Cookie: session=5f74890ac395e36ee3f7f5b0fed07f9045c51694%7E4d5c13367c2082.44169646; expires=Fri, 25-Mar-2011 00:35:17 GMT; path=/"
...

Changes with nginx 0.8.44:

    *) Change: now nginx does not cache by default backend responses, if 
       they have a "Set-Cookie" header line.

Чтобы кешировать такие ответы (и убрать из них заголовок Set-Cookie):

    fastcgi_ignore_headers Set-Cookie;
    fastcgi_hide_header Set-Cookie;

Ну или бекенд поправить, что правильнее.

To Igor:

Доки обнови, pls.

http://sysoev.ru/nginx/docs/http/ngx_http_fastcgi_module.html#fastcgi_ignore_headers
http://sysoev.ru/nginx/docs/http/ngx_http_proxy_module.html#proxy_ignore_headers

Ну или накати патч [1] и потом обнови. :)

[1] http://nginx.org/pipermail/nginx-devel/2011-February/000738.html

Maxim Dounin



Подробная информация о списке рассылки nginx-ru