Hi i'm a newbie in Varnish HTTP-Cache. I find it hard to understand the difference in concept between purging and banning cache invalidation.
Anyone who can explain and differentiate banning and purging in varnish http-cache?
Anyone? Thanks!
Hi i'm a newbie in Varnish HTTP-Cache. I find it hard to understand the difference in concept between purging and banning cache invalidation.
Anyone who can explain and differentiate banning and purging in varnish http-cache?
Anyone? Thanks!
Basically the difference between Purge and Ban is hard and soft delete but they will both update your cache. However there are some further little details that distinguish them:
Purge: Removes the object from cache immediately. It will work only for the specific url that is being requested and it is not possible to use regular expressions with Purge. For example: a Purge for www.example.com/uri is called, only the object for this URL will be removed from cache.
Ban: It is used when you want to remove many objects at once. This can be accomplished using regular expressions that are not available in Purge. When Ban is used a rule is created inside Varnish to invalidate objects, every object that is requested to Varnish will be checked against this rule and updated if it matches. This rule will check only objects older than it and will stay in Varnish as long as there is an object older than it is. This procedure avoids the invalidation of the same object more than
once. A practical example would be that you want to ban all the .png objects. Using the Varnish Cli you issue the command ban req.url ~ "\\.png$"
. Every time an object that matches this condition is requested from cache it will be discarded, a new version of it will be generated and delivered to the client. Objects generated after the rule are not going to be checked.
If you want some practical examples and how to code it, maybe you should check this answer.
© 2022 - 2024 — McMap. All rights reserved.