I have some complex interaction going on here and I would like to see
if anybody has some suggestions for me.
I have Nginx in front of apache serving static files, performing
compression and SSL. For large files, I use X-Accel-Redirect header to
offload the sending to nginx. This all works beautifully.
However, the problem is that the backend tracks downloads, it only
allows a certain number of downloads per file. Some of these files are
PDFs that are opened on the client side using Acrobat Reader. Acrobat
Reader sends Range requests to nginx.
Nginx will then forward the range request to apache, which returns a
200 including the X-Accel-Redirect header. Nginx then pulls the
correct range from the indicated file and returns that to the client
with a 206 status.
The problem is, each of these range requests is counted by my backend
as a download, expiring the download counter prematurely.
My thought on a possible solution is to simply turn on caching in
nginx, allowing it to satisfy subsequent range requests without
hitting the backend. Something like the following:
However, I am curious if the proxy_cache_valid directive matches on
the response code of the backend, or the response code that nginx will
send to the client. Also, how does proxy_cache interact with