httpcache icon indicating copy to clipboard operation
httpcache copied to clipboard

Manual evictions

Open dahankzter opened this issue 9 years ago • 3 comments

I find varnish cache BAN functionality very neat and it would be nice to be able to use it here as well. Right now a key hash is calculated and stored which makes wildcard bans problematic.

Also there seems to be no easy way to manually do something like this:

cache.Invalidate(path) because of how keys are created (I may very well be wrong here...)

I tried using the underlying VFS (memory) but again it seems to fail on how keys are created.

Is there a way to do this currently? I have handlers in place to intercept so I think I just need a way to deterministically calculate keys.

As for wildcards any ideas would be welcome keeping another set of currently seen keys may work but seems redundant and error prone at best.

dahankzter avatar Feb 10 '16 11:02 dahankzter

Varnish's BAN functionality is basically a filter that won't let certain content be served from cache, but it doesn't do any invalidation or eviction.

Varnish's PURGE is probably closer to what you want. I'll do some thinking about how to support this in the next major version I've been thinking about.

lox avatar Feb 23 '16 22:02 lox

Actually ban now evicts once it hits a matching entry. Also purge only work on exact matching objects if I am not mistaken. https://www.varnish-cache.org/docs/4.1/users-guide/purging.html

Ban-like functionality would be cool because it would allow for easy invalidation of all related objects. For example we often have resources with large json payloads that gets effectively cached but we also allow for the api to return parts of the same json as sub resources. Being able to efficiently ban/evict all such (sub)resources when a change happens would be really neat.

dahankzter avatar Feb 24 '16 08:02 dahankzter

@dahankzter In the case you would want do something like varnish BAN, you would be able to implement it in the upper levels of the software such as the handler. I am not sure that what you are looking for but this is a working example: https://gist.github.com/elico/9bb3da6b7937ce09a0c2d91637b3be5c I have used this idea to pass traffic into the caching proxy only for specific sites and files.

elico avatar Jun 12 '16 22:06 elico