Nginx cache file is too small
kkobylyanskiy
nginx-forum at forum.nginx.org
Thu Apr 22 08:51:59 UTC 2021
Hi,
I'm using Nginx as a reverse-proxy to cache my POST request and wrote the
following config:
http {
gzip on;
gzip_proxied any;
gzip_types text/plain application/json;
gzip_min_length 1000;
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=FLOWS:100m
inactive=24h max_size=2g use_temp_path=off;
server {
listen 3200;
location /api/flows-page-v1 {
proxy_pass http://app:3000/api/flows-page-v1;
proxy_set_header Host $host;
proxy_buffering on;
proxy_cache FLOWS;
proxy_cache_methods POST;
proxy_cache_key "$request_uri|$request_body";
proxy_cache_valid 200 1d;
client_body_buffer_size 512k;
proxy_buffers 6 128k;
proxy_buffer_size 512k;
proxy_busy_buffers_size 512k;
proxy_cache_use_stale error timeout invalid_header updating
http_500 http_502 http_503 http_504;
add_header X-Cached $upstream_cache_status;
}
}
}
I'm getting the following error when trying so send a request for the second
time after the first on is cached:
[crit] 20#20: *2 cache file
"/var/cache/nginx/6/fb/bee5677b8b46add7cfef279105773fb6" is too small
I logged in to the container and verified that this file contains cached
content.
>From the source code it seems like the following fragment causes this error
and therefore cache MISS (nginx/src/http/ngx_http_file_cache.c):
if ((size_t) n < c->header_start) {
ngx_log_error(NGX_LOG_CRIT, r->connection->log, 0,
"cache file \"%s\" is too small", c->file.name.data);
return NGX_DECLINED;
}
I already found the similar question -
https://forum.nginx.org/read.php?2,271756 but the answer doesn't seem to be
related to my situation: I run nginx in docker-compose, therefore there is
no any temporary files left in the cache directories, as well as the other
nginx process.
What should I do to avoid this error?
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,291344,291344#msg-291344
More information about the nginx
mailing list