简体   繁体   中英

How to extract and decode base64 parameter in Varnish VCL

In order to invalidate the cache, I'm encoding an url the following way:

$clean_url = base64_encode( $url );

http://url_of_the_varnish_host_to_clean/clean/url?v=$clean_url

I would like to catch this url to clean and decode it in my vcl file. I catch the request this way:

if (req.url ~ "^/clean/url?v=") 

But I have no idea how to catch the parameter and decode it.

You will at very least need vmod_digest which provides digest.base64_decode function.

Also, your regex is a bit wrong, should be:

if (req.url ~ "^/clean/url\?v=") 

That said, why does your invalidation logic has to be so complex? Why not do it standard way - ie check against matches of purger IP against defined ACL and invalidate the URL of PURGE request (not parameter).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM