<div dir="ltr"><div>Using the embedded Lua module you can add the three IDs as integers and reduce it to a single number. <br></div><div>That way you'll get a single number by virtue if the commutativity of real number addition. AFAIK there <div>
are no arithmetic operators available on the Nginx config language.</div><div><br></div></div></div><div class="gmail_extra"><br clear="all"><div>----appa<br><br></div>
<br><br><div class="gmail_quote">On Sat, May 18, 2013 at 2:52 PM, roysmith649 <span dir="ltr"><<a href="mailto:nginx-forum@nginx.us" target="_blank">nginx-forum@nginx.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
We've got a route which is used to retrieve multiple objects in parallel.<br>
The client does a GET on /api/1/station/multi?id=123&id=456&id=789. We<br>
cache these in our nginx config:<br>
<br>
location ~ /api/[^/]+/station/multi {<br>
proxy_pass <a href="http://localhost:8000" target="_blank">http://localhost:8000</a>;<br>
proxy_set_header X-Real-IP $remote_addr;<br>
proxy_set_header Host $host;<br>
proxy_set_header X-Forwarded-Host $host;<br>
proxy_set_header X-Forwarded-Server $host;<br>
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br>
<br>
proxy_cache api;<br>
proxy_cache_use_stale updating;<br>
}<br>
<br>
The problem is, clients present the ids in random order. For example, one<br>
client might ask for id=1&id=2, and another ask for id=2&id=1. Both should<br>
return exactly the same response, but map to different cache keys. For two<br>
ids, it's not that bad, but many of the calls are for large numbers of ids<br>
and the combinatorics quickly spin out of control.<br>
<br>
Is there any way to rewrite the keys in nginx to canonicalize them? Sorting<br>
all the ids in numerical order would do it.<br>
<br>
Posted at Nginx Forum: <a href="http://forum.nginx.org/read.php?2,239315,239315#msg-239315" target="_blank">http://forum.nginx.org/read.php?2,239315,239315#msg-239315</a><br>
<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>