Nginx Caching of REST API Nginx Caching of REST API nginx nginx

Nginx Caching of REST API


It is common to pass API version in the URI path (check out this question too). I'd suggest to use the second option, although rewrite it as /api/1.2.2/tilemenus, which looks more similar to how APIs operate on a bunch of popular websites.


In my opinion, #2 is better, because you enforce the guarantee that a specific URL always returns the same resource/data, and, yes, you can safely cache it.

Plus, it makes it easier to track version usage just by analyzing HTTP server logs.

And it even spares you the effort of keeping track of user version, since the #2 makes it explicit by the request URL itself