Hi again,

two messages in a day after a few years :-)

I have code similar to the following (also here[1]):

    sub vcl_recv {
        ...
        call rate_limit;
        ...
    }

    # Throttling based on request inspection
    sub rate_limit {

        if (req.url ~ "pattern1") {
           std.log("pattern1 requests must never be throttled");
           return; # <---- Need to return early here, but can't do it
        }

        if (req.url ~ "pattern2") {
           if (vsthrottle.is_denied("pattern2" + client.identity, 100, 10s)) {
               std.log("pattern2 throttling for ip " + client.identity);
               return(synth(429, "ETOOMANYREQUESTS"));
           }
        }

        if (vsthrottle.is_denied("ip:" + client.identity, 500, 10s)) {
            std.log("global throttling for ip " + client.identity);
            return(synth(429, "ETOOMANYREQUESTS"));
        }

    }

Ideally, I'd like to return early from rate_limit() when I know that I don't 
need
to enforce any rate limiting for some types of requests, but I understand
that's not implemented.

I found some alternatives, though generally they feel uglier.
Any ideas?

-- 
Cosimo

[1] 
https://gist.github.com/cosimo/6d3318bf173357dfb2652b7b2e81e1e0#file-gistfile1-txt-L18
_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

Reply via email to