<div dir="ltr">Hello,<div><br></div><div>I have a flask web app + uwsgi + nginx.</div><div>I am using nginx both as server as well as proxy server.</div><div><br></div><div><b>How to make nginx to cache successful results from all API ending points <i>but</i> one?</b></div><div><br></div><div>I want to cache <i>only successful responses </i>from  all /api/endpoints except /api/search.</div><div><br></div><div>1. I tried to:</div><div> -- add a new location (see api/search) to the proxy server to <b>proxy_pass</b> the request to default server;</div><div>-- put all other /api/ location blocks with cache settings <i>after </i> the<i> /api/search</i> location</div><div><br></div><div>It seems not to cache as I want (It is caching everything).</div><div><br></div><div><br></div><div>2. I designed my webapps like this (see mockup in attachment):</div><div> -- 1 api return a page; if page is not found, <i>it returns a json formatted warning</i><br>'{warning : not found'}</div><div> -- 1 template handle 404 missing pages</div><div><br></div><div>To say, while</div><div><a href="http://example.com/api/mockup">example.com/api/mockup</a> will return a result (200 response)</div><div>example/mockup will return a 404 response</div><div><br></div><div>In case page is not found, will nginx cache the api result or not given my current settings?<br></div><div><br></div><div>Could you clarify how flask, uwsgi and nginx server (port 8000) and nginx proxy server  (port 80) are interacting in such a case, given my settings?</div><div><br></div><div>**</div><div><br></div><div>Please see in attachment blocks from my nginx settings.</div><div>Uwsgi settings are  below.</div><div><br></div><div><i>** UWSGI # settings in myapp.ini **</i></div><div>







<p class="gmail-p1">[uwsgi]</p>
<p class="gmail-p1">module = wsgi</p>
<p class="gmail-p1">master = true</p>
<p class="gmail-p1">processes = 5</p>
<p class="gmail-p1">socket = awesome3.sock</p>
<p class="gmail-p1">chmod-socket = 660</p>
<p class="gmail-p1">vacuum = true</p>
<p class="gmail-p1">die-on-term = true</p>
<p class="gmail-p1">logto = /var/log/uwsgi/%n.log</p>
<p class="gmail-p1">protocol = uwsgi</p>
<p class="gmail-p1">harakiri = 120</p><p class="gmail-p1"><br></p><p class="gmail-p1"><br></p><p class="gmail-p1">***</p><p class="gmail-p1"><br></p><p class="gmail-p1">Thank you so much for helping out!</p></div></div>