Welcome! Log In Create A New Profile

Advanced

Re: Merging equivalent cache keys?

António P. P. Almeida
May 18, 2013 09:46AM
Using the embedded Lua module you can add the three IDs as integers and
reduce it to a single number.
That way you'll get a single number by virtue if the commutativity of real
number addition. AFAIK there
are no arithmetic operators available on the Nginx config language.


----appa



On Sat, May 18, 2013 at 2:52 PM, roysmith649 <nginx-forum@nginx.us> wrote:

> We've got a route which is used to retrieve multiple objects in parallel.
> The client does a GET on /api/1/station/multi?id=123&id=456&id=789. We
> cache these in our nginx config:
>
> location ~ /api/[^/]+/station/multi {
> proxy_pass http://localhost:8000;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header Host $host;
> proxy_set_header X-Forwarded-Host $host;
> proxy_set_header X-Forwarded-Server $host;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>
> proxy_cache api;
> proxy_cache_use_stale updating;
> }
>
> The problem is, clients present the ids in random order. For example, one
> client might ask for id=1&id=2, and another ask for id=2&id=1. Both should
> return exactly the same response, but map to different cache keys. For two
> ids, it's not that bad, but many of the calls are for large numbers of ids
> and the combinatorics quickly spin out of control.
>
> Is there any way to rewrite the keys in nginx to canonicalize them?
> Sorting
> all the ids in numerical order would do it.
>
> Posted at Nginx Forum:
> http://forum.nginx.org/read.php?2,239315,239315#msg-239315
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Merging equivalent cache keys?

roysmith649 May 18, 2013 08:52AM

Re: Merging equivalent cache keys?

António P. P. Almeida May 18, 2013 09:46AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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