You probably want something like the following (untested):
######################################
if(req.url ~ "/\d+\.jpg$"){
set req.http.X-Image-Int = req.url;
regsub( req.http.X-Image-Int, "/(\d+)\.jpg$", "\1");
if(std.integer(req.http.X-Image-Int, 0) > 10) {
set req.backend = foo;
}
elseif(std.integer(req.http.X-Image-Int, 0) > 5) {
set req.backend = foo2;
}
remove req.http.X-Image-Int;
}
######################################
~Paul
On Wed, Oct 10, 2012 at 12:42:22AM +0000, Ross Brown wrote:
> Hi all
>
> We use Varnish for accelerating images. They are uploaded by our users and
> given a numeric ID, which is allocated sequentially. We have a lot of them.
>
> I'm about to start storing newly-uploaded in a different place, and ideally
> would like to select a backend by doing a compare against the image ID, eg if
> the ID > a number, use a different backend. Otherwise the backend will have
> to check both storage locations to find the image.
>
> I could do this with a regex, but ideally I'd like to do a proper integer
> comparison. I have read about the integer function in vmod_std, but I don't
> see how I use that when the integer is part of the request URL.
> https://www.varnish-cache.org/docs/3.0/reference/vmod_std.html?highlight=vmod_std#integer
>
> Request URLs look similar to this: /photoserver/size/1234567.jpg
>
> Any ideas?
>
>
> _______________________________________________
> varnish-misc mailing list
> [email protected]
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
________________________________
This message may contain confidential or privileged information. If you are not
the intended recipient, please advise us immediately and delete this message.
See http://www.datapipe.com/legal/email_disclaimer/ for further information on
confidentiality and the risks of non-secure electronic communication. If you
cannot access these links, please notify us by reply message and we will send
the contents to you.
_______________________________________________
varnish-misc mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc