October 08, 2015 05:10AM
Коллеги, всем привет!

Возникла нужда кратковременно кешировать ответы backend'a. Проблема в том,
что надо не только код 200, но и 400.

Попробовал так (в лоб):

proxy_cache_path /var/cache/nginx/apicache levels=1:2
keys_zone=apicache:10m;

location /api {
<...>

proxy_cache apicache;
proxy_cache_use_stale error timeout updating;
proxy_cache_lock on;
proxy_cache_valid any 30s;
* proxy_cache_valid 400 30s;*
proxy_cache_methods POST;
proxy_cache_key "$request_uri|$request_body";

proxy_ignore_headers X-Accel-Expires Expires Cache-Control;

add_header X-Cached $upstream_cache_status;
}

Не помогло! Если на код 200 в ответе появляется заголовок:

HTTP/1.1 200 OK
Server: nginx
Date: Thu, 08 Oct 2015 08:54:38 GMT
Content-Length: 0
Connection: keep-alive
*X-Cached: HIT*

то на 400 его уже нет:

HTTP/1.1 400 Bad Request
Server: nginx
Date: Thu, 08 Oct 2015 08:54:30 GMT
Content-Length: 0
Connection: keep-alive

ЧЯДНТ?

--
Best regards, Juriy Strashnov

Please consider the environment before printing this email.
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
Subject Author Posted

"proxy_cache_valid 400" -- возможно ли?

foboss October 08, 2015 05:10AM

Re: "proxy_cache_valid 400" -- возможно ли?

Sergey Kandaurov October 08, 2015 06:22AM

Re: "proxy_cache_valid 400" -- возможно ли?

foboss October 08, 2015 06:36AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 277
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready