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

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

link|improve this question

56% accept rate
feedback

1 Answer

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;
}
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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