Maxim Dounin
January 11, 2017 12:44PM
Hello!

On Wed, Jan 11, 2017 at 12:23:08PM -0500, bdesemb wrote:

> I want to add some clarification. My client calls is like "/app" and the
> server respond with a name. My file is stored at /var/local/data/<name>. I
> want to cache the response. So if I have another request on /app, Nginx
> should respond with the cached version of the file.

It is not clear what do you mean by "cached version of the file",
and what exactly do you want to cache.

Original question you are referring to was about caching responses
with the X-Accel-Redirect header. Files as referenced in these
X-Accel-Redirect responses are expected to exist permanently. The
question was how to cache responses with X-Accel-Redirect header
to avoid asking backend application each time, and return files
directly instead (using cached X-Accel-Redirect responses). I've
provided the configuration which does this.

If in your case files are generated by your app and then removed,
then this configuration will not work for you. Instead, you need
to cache full responses at the frontend level, and use an
additional backend nginx to resolve X-Accel-Redirect redirections.
That is, something like this:

server {
server 8080;

location / {
# here caching happens
proxy_pass http://127.0.0.1:8081;
proxy_cache foo;
}
}

server {
server 8081;

location / {
# here X-Accel-Redirect is processed
proxy_pass http://real-upstream-server;
}

location /path/to/files {
# a location to access files after X-Accel-Redirect
...
}
}

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

proxy_cache seems not working with X-Accel-Redirect

gray August 09, 2013 06:20AM

Re: proxy_cache seems not working with X-Accel-Redirect

Maxim Dounin August 16, 2013 10:34PM

Re: proxy_cache seems not working with X-Accel-Redirect

bdesemb January 11, 2017 07:39AM

Re: proxy_cache seems not working with X-Accel-Redirect

Maxim Dounin January 11, 2017 09:34AM

Re: proxy_cache seems not working with X-Accel-Redirect

bdesemb January 11, 2017 11:10AM

Re: proxy_cache seems not working with X-Accel-Redirect

bdesemb January 11, 2017 12:23PM

Re: proxy_cache seems not working with X-Accel-Redirect

Maxim Dounin January 11, 2017 12:44PM

Re: proxy_cache seems not working with X-Accel-Redirect

bdesemb January 12, 2017 07:54AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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