multiple purge/ban in one http request

Hauke Lampe lampe at hauke-lampe.de
Tue Dec 4 23:24:29 CET 2012


On 04.12.2012 15:11, konrad rzentarzewski wrote:

> does anybody has experiences abt. injecting many purge/bans in
> 1 connection (ie. 50-100)?

No, never tried it yet.

> ie. i have several X-Ban headers that i want to process.
 >
 > BAN / HTTP/1.0
 > Host: example.com
 > X-Ban: /article2702/esi8018
 > X-Ban: /article26502/esi8701

You can transform the X-Ban headers into a ban expression with 
std.collect and regsuball:

| if (req.request == "BAN") { // && auth
|     std.collect(req.http.X-Ban); // Combine X-Ban headers, separated 
by ", "
|     std.log("banning URLs: " + req.http.X-Ban);
|     ban("obj.X-Purge-URL ~ (" + regsuball(req.http.X-Ban, ", ", "|") + 
")");
|     error 200 "Added to ban-list";
| }

A very large number of X-Ban headers in a single request could exceed 
workspace limits and require changes to runtime parameters 
(sess_workspace, http_max_hdr, http_req_hdr_len, http_req_size)

 > i think it needs to be done with inline-c and vrt.

Indeed, it might be better to iterate over the headers in an Inline-C loop.


Hauke.




More information about the varnish-misc mailing list