<div dir="ltr">Am completely sure its possible, am just not the nginx specialist, so i might not point you to the best directions.<div><br></div><div>But as far as i understand in my little time together with things beautiful thing called nginx, you should have a look on this:</div>
<div><br></div><div><a href="http://wiki.nginx.org/HttpCoreModule#root">http://wiki.nginx.org/HttpCoreModule#root</a><br></div><div><br></div><div style>let me know the results you achieve, since i'll be soon passing by the same problem :P</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 18 April 2013 17:19, <span dir="ltr"><<a href="mailto:kristofer@cybernetik.net" target="_blank">kristofer@cybernetik.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><div>Hello,</div><div><br></div><div>I am using nginx as a reverse proxy to cache content for an application. Requests to the application are expensive, so I would like to set up caching so that if the file exists in nginx, it won't even bother querying the backend server.</div>
<div><br></div><div>I can't seem to figure out what I am missing.</div><div><br></div><div>This is how I am set up:</div><div><p style="padding-left:30px">location /download {<br> index index.html index.htm;<br> proxy_pass <a href="http://x.x.x.x/download" target="_blank">http://x.x.x.x/download</a>;<br>
proxy_set_header X-Real-IP $remote_addr;<br> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br> proxy_set_header Host <a href="http://application.domain.com" target="_blank">application.domain.com</a>;<br>
proxy_set_header Accept-Encoding "";<br> proxy_ignore_headers Set-Cookie X-Accel-Expires Expires Cache-Control;<br> if_modified_since off;<br> add_header X-Cache-Status $upstream_cache_status;</p>
<p style="padding-left:30px"> proxy_cache_valid 200 24h;<br> expires 168h;<br> proxy_cache staticfilecache;<br> }</p><p style="padding-left:30px">proxy_cache_path /var/www/nginxcache/ levels=1:1:2 keys_zone=staticfilecache:2000m inactive=10800m;<br>
proxy_cache_key "$scheme$host$request_uri$cookie_user";</p><p>So for all requests to /download, I want it to serve strictly from the cache. I do not want it to query the proxy_pass location at all (not even for last modified time) if the file exists in the local cache. I just want it to serve the cached copy and be done.</p>
<p>Is this possible?<br><br></p></div></div></div><br>_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br></blockquote></div><br></div>