Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I instruct nginx to cache a particular page for a fixed duration?

Say I have a home page at Now I want nginx to cache this for 5 mins and then hit apache to take the new one. How do I do this?

share|improve this question
up vote 1 down vote accepted

Setup a cache zone and configure a specific location to be cached with the nginx proxy/cache module. There's a blog post about a simple setup. Basically you need to create a place associated with a zone:

proxy_cache_path /var/cache/nginx keys_zone=anonymous:10m;

and then assign stuff to be cached on that zone:

location / {
    proxy_pass    http://localhost:8080/;
    proxy_cache   anonymous;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.