Welcome! Log In Create A New Profile

Advanced

Nginx cache file is too small

April 22, 2021 04:51AM
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?
Subject Author Posted

Nginx cache file is too small

kkobylyanskiy April 22, 2021 04:51AM

Re: Nginx cache file is too small

kkobylyanskiy April 22, 2021 08:10AM

Re: Nginx cache file is too small

Maxim Dounin April 22, 2021 10:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 287
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