Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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

 
discard

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.