Manual evictions
dahankzter opened this issue · 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.
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.
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 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.