Hello! On Mon, Feb 05, 2018 at 04:08:33AM -0500, loopback_proxy wrote:
> I am new to nginx caching but have worked with nginx a lot. I tried enabling > caching feature in our repository but it never worked so I thought I will > pull a fresh copy of nginx and turn it on. I ended with the same issue. For > some reason, nginx is not able to create the cache file in the cache dir. I > have already turned on proxy buffering and set full rw permission for all > users on the cache dir. I also gdb'ed the code and it seems like it gets > into ngx_open_and_stat_file from ngx_open_cached_file ( > http://lxr.nginx.org/source/src/core/ngx_open_file_cache.c?v=nginx-1.12.0#0144 > ) and it tries to open an non existent file in RDONLY mode if the of->log is > not set ( > http://lxr.nginx.org/source/src/core/ngx_open_file_cache.c?v=nginx-1.12.0#0869 > ) The code in question is not related to your problem. Instead, you should check what your backend returns. There are number of cases when nginx won't cache a response, see description of the proxy_cache_valid directive for the details: http://nginx.org/r/proxy_cache_valid [...] > And here's the debug log showing whats that nginx is failing to create the > cache file. > 2018/02/05 08:57:26 [debug] 22509#0: *7 http cache key: > "http://52.216.66.40" > 2018/02/05 08:57:26 [debug] 22509#0: *7 http cache key: > "/teddy-clip-art-teddy-md.png" > 2018/02/05 08:57:26 [debug] 22509#0: *7 add cleanup: 00000000006D3560 > 2018/02/05 08:57:26 [debug] 22509#0: shmtx lock > 2018/02/05 08:57:26 [debug] 22509#0: slab alloc: 120 slot: 4 > 2018/02/05 08:57:26 [debug] 22509#0: slab alloc: 00007FD2C31AA080 > 2018/02/05 08:57:26 [debug] 22509#0: shmtx unlock > 2018/02/05 08:57:26 [debug] 22509#0: *7 http file cache exists: -5 e:0 > 2018/02/05 08:57:26 [debug] 22509#0: *7 cache file: > "/tmp/nginx/cache/3/4f/ecbc29d001e852b40f09e913b5ced4f3" > 2018/02/05 08:57:26 [debug] 22509#0: *7 add cleanup: 00000000006D35B0 > 2018/02/05 08:57:26 [debug] 22509#0: *7 http upstream cache: -5 Your assumption that it is "failing to create" is wrong. Instead, this debug log snippet shows that nginx checked if there is a cached response available, and the result is negative. -- Maxim Dounin http://mdounin.ru/ _______________________________________________ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx