proxy_cache and X-Accel-Redirect

Igor A. Ippolitov iippolitov at
Tue Jun 27 06:53:28 UTC 2017

Hello, deivid__

As you are using uwsgi_pass, you may want to try uwsgi_cache 
uwsgi_cache_path and uwsgi_cache_key directives.

To make use of $upstream_status you should move your upstream to a 
separate block like:
upstream backend1 {
   server unix:///tmp/backend.sock;

And then use 'backend1' inside uwsgi_pass directive like:
uwsgi_pass uwsgi://backend1;

On 26.06.2017 20:39, deivid__ wrote:
> Hi,
> I currently get requests that are resolved with an external server to a file
> with X-Accel-Redirect:
> for example:
> /data/asd-asd-asd -> proxied to a backend -> resolves to file.xls
> /data/qqq-qqq-qqq -> proxied to a backend -> resolves to file.xls
> /data/123-123-123 -> proxied to a backend -> resolves to image.jpeg
> I want to cache the resulting files with nginx, as the initial access is
> very costly (they are accessed over the network). On first access they
> should be copied to a local cache, following requests should also go to the
> backend but actually serve the file from cache.
> My current config:
> Note: The files are quite large (up to 4gb)
> I added the proxy_cache directives to both the requests path and the
> internal path but none of them are working.
> /cache/ is never populated, and the X-*-Cache headers are not present in the
> response
> Posted at Nginx Forum:,275138,275138#msg-275138
> _______________________________________________
> nginx mailing list
> nginx at

More information about the nginx mailing list