Using nginx and/or varnish to cache server-generated 301 redirects

Posted by rlotun on Server Fault See other posts from Server Fault or by rlotun
Published on 2010-12-08T18:27:52Z Indexed on 2012/08/29 9:40 UTC
Read the original article Hit count: 256

Filed under:
|
|
|

I'm implementing a sort of url-shortener service. What happens is that I have some backend app server that takes in a request, does some computation and returns a 301 redirected url back upstream to an nginx frontend:

request --->   nginx  ---->  app_server

What I want to be able to do is cache this returned 301 url for the same request (a specific url with a "short code").

Does nginx do this caching automatically? Or should I drop in something like varnish in between nginx and the app_server? I can easily cache this in memcache, but that would require hitting the app_server, which I'm sure can be dispensed with after the first request.

Thanks.

© Server Fault or respective owner

Related posts about nginx

Related posts about http