Thanks, Maxim, for correcting my misunderstanding.

With what frequency is the cache manger run?

Roger

> On Apr 3, 2020, at 9:26 AM, Maxim Dounin <mdou...@mdounin.ru> wrote:
> 
> Hello!
> 
> On Fri, Apr 03, 2020 at 08:33:43AM -0700, Roger Fischer wrote:
> 
>>> You can just set the inactive time longer than your possible maximum expire 
>>> time for the objects  then the cache manager won't purge the cache files 
>>> even the object is still valid but not accessed.
>> 
>> That may only have a small impact.
>> 
>> As far as I understand:
>> NGINX will remove an item only when the cache is full (ie. it needs space 
>> for a new item).
>> Items are removed based on the least-recently used (LRU) queue.
>> The least-recently-used (last) item in the LRU queue is unconditionally 
>> removed.
>> The second and third last items are removed if they are past the invalid 
>> time.
> 
> Your understanding is wrong.  Cache manager always removes all 
> items which were not access for the "inactive=" period of time.  
> Quoting docs (http://nginx.org/r/proxy_cache_path):
> 
> : Cached data that are not accessed during the time specified by the 
> : inactive parameter get removed from the cache regardless of their 
> : freshness. By default, inactive is set to 10 minutes.
> 
> See ngx_http_file_cache_expire() function for details.
> 
> Additionally, cache items can be removed based on the "max_size=" 
> parameter of the "proxy_cache_path" directive, or if there isn't 
> enough room in the "keys_zone=" shared memory zone.
> 
>> The expiry of an item has no influence on the removal of items. 
>> It only affects if the item is delivered from the cache, or 
>> revalidated with an upstream request.
> 
> That's correct, as long as "expire" is meant to be the time from the 
> Expires / X-Accel-Expires / Cache-Control / proxy_cache_valid.  In 
> nginx documentation this is called "caching time".
> 
> -- 
> Maxim Dounin
> http://mdounin.ru/
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Reply via email to