Welcome! Log In Create A New Profile

Advanced

Re: caching issues with nginx as reverse-proxy

Maxim Dounin
June 30, 2016 08:52AM
Hello!

On Thu, Jun 30, 2016 at 12:02:29AM +0200, dm@whocaresabout.de wrote:

> currently I am serving files with a size about 1,5G (static without dynamic
> content) using a hand full of nodes and nginx in reverse proxy setup.
> Caching works, ..but not as expected. During the requests nginx creates a
> lot of temp caching files that grow up to the size of the origin file
> delivered from backend server. It's kinda weird that even if the inactive
> caching time out is not reached, the file is randomly downloaded again from
> backend.

Multiple temporary files can be created when the response is not
yet cached and there are multiple requests to the resource in
question. Once the response is cached it will be returned from
cache to subsequent requests, and no additional temporary files
will appear.

To mininize parallel caching by multiple simultaneous requests
there is the "proxy_cache_lock" directive. Though for 1.5G files
default timeouts it uses may not be enough, consider tuning
proxy_cache_lock_age and proxy_cache_lock_timeout:

http://nginx.org/r/proxy_cache_lock_age
http://nginx.org/r/proxy_cache_lock_timeout

Additionally, consider using the slice module. It was specially
designed to improve caching of large files, see here:

http://nginx.org/en/docs/http/ngx_http_slice_module.html

[...]

> proxy_cache_path /var/tmp/nginx-cache/rproxy levels=1:2
> keys_zone=rproxy:260m max_size=5g inactive=260m use_temp_path=off;

Note well: with "max_size" set to 5g the cache in question can
hold about 3 1.5G files. It may not be what you want for
effective caching.

[...]

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

caching issues with nginx as reverse-proxy

Anonymous User June 29, 2016 06:04PM

Re: caching issues with nginx as reverse-proxy

Francis Daly June 30, 2016 03:16AM

Re: caching issues with nginx as reverse-proxy

Maxim Dounin June 30, 2016 08:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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