Mailing List Archive

Re: Caching a resource after specific number of requests
On Tue, Dec 3, 2019 at 6:04 PM al sefid <sefidmou@yahoo.com> wrote:
>
> Hello there!
> Is there any functionality like proxy_cache_min_uses in the Varnish cache that caches a resource after specific number of requests to that resource?
> Thank you!

Varnish is not capable of doing that by itself, but as Geoff pointed
out on github you could rely on some form of throttling to emulate
this functionality, but that requires a third-party module:

https://github.com/varnishcache/varnish-cache/issues/3150#issuecomment-561307014

Be careful though, his example was a bit simplistic (I assume on
purpose to show the idea) and shouldn't be used as-is.

It might also not work if you have an object in your cache that
outlives the throttling. Maybe the cat flap could work for this case,
but here be dragons...

I moved the discussion to the misc mailing list because this is not
(yet?) dev material.

While this may sound like a good idea, and while it works for nginx,
it might not be a good fit for varnish. Of course unless we have that
feature in place, it's also hard to tell whether this would benefit
your workload, I suspect it would make things worse or force us to
make other changes. In particular, making this a global configuration
could be highly detrimental if you have some variety of contents in
your cache (small, big, short- and long-lived etc) and the best place
to start is to have the backend tell you precisely all about responses
you may be able to cache or not and how instead of starting with an a
priori criteria that a response shouldn't be cached unless it's asked
at least 3 times (which is a very vague requirement).

Dridi
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Caching a resource after specific number of requests [ In reply to ]
On 12/5/19 11:24, Dridi Boukelmoune wrote:
> On Tue, Dec 3, 2019 at 6:04 PM al sefid <sefidmou@yahoo.com> wrote:
>>
>> Is there any functionality like proxy_cache_min_uses in the
>> Varnish cache that caches a resource after specific number of
>> requests to that resource?
>
> Varnish is not capable of doing that by itself, but as Geoff pointed
> out on github you could rely on some form of throttling to emulate
> this functionality, but that requires a third-party module:
>
> https://github.com/varnishcache/varnish-cache/issues/3150#issuecomment-561307014
>
> Be careful though, his example was a bit simplistic (I assume on
> purpose to show the idea) and shouldn't be used as-is.

Right, and also not tested.


HTH nevertheless,
Geoff
--
** * * UPLEX - Nils Goroll Systemoptimierung

Scheffelstraße 32
22301 Hamburg

Tel +49 40 2880 5731
Mob +49 176 636 90917
Fax +49 40 42949753

http://uplex.de