proxy_cache: Activity vs. Validity

janedenone nginx-forum at nginx.us
Wed Sep 29 14:20:19 MSD 2010


Hi,

I am new to nginx (and to caching proxies), and I'd like to make sure I
use the Proxy module correctly. As far as I understand, the following
directive

proxy_cache_path  /data/nginx/cache/one    levels=1     
keys_zone=one:10m inactive=10m max_size:500m;

asks nginx to cache a certain page for 10 minutes. If it is not
requested again within that time span, the page is removed from the
cache. I assume that without the inactive parameter, pages remain in the
cache until either the maximum zone size (10 MB) or the maximum cache
size (500 MB) is reached.

Now I wonder how the proxy_cache_valid contributes to the caching
mechanism. The wiki
(http://wiki.nginx.org/NginxHttpProxyModule#proxy_cache_valid) says that
there is no persistent caching without proxy_cache_valid – but what
does that mean exactly? A configuration without proxy_cache_valid works
(pages are cached, and cached pages are sent back to the client), so
what is different with proxy_cache_valid?

Also, how does proxy_cache_valid relate to the inactive parameter above?
If, for example, I set proxy_cache_valid for for any response to 10
minutes, but the inactive parameter to 20 minutes, cached pages will
remain in the cache for 10 minutes after they have become invalid (i.e.
if the page is requested 15 minutes after the initial request, the
existing cache entry is ignored). If this assumption is correct, it
probably makes no sense to set the inactive parameter to a higher value
than proxy_cache_valid.

Best regards,
Jan

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,135262,135262#msg-135262




More information about the nginx mailing list