My devs are asking me to Do many many redirects based on various mispellings our our URL’s. I am worried about the extra processing of every request going through these lists of if/then statements. Is there a more processor/network friendly way to write this? Keep in mind im actually talking about adding like 30 of these, this is a small sampling. I dont want to over tax the LB or slow down my responses. Any help would be greatly appriciated.
The most efficient option might be to get a new IP address to resolve all the alternate spellings to and then use however complicated an iRule that you want.
Else, if you need to stick with one address, you can put the real hostname first in a switch statement and the rest afterward. That way you would only do one evaluation of the host header value for the majority of requests. I don’t think evaluating the host header several times in a switch statement would add that much overhead anyhow, but it’s always good to try to make things as efficient as possible.
when HTTP_REQUEST {
Check the requested host header (set to lowercase)
switch [string tolower [HTTP::host]] {
"realdomain.example.com" {
do nothing
}
"alternatespelling1.example.com" {
check the URI and/or redirect request
}
"alternatespelling2.example.com" {
check the URI and/or redirect request
}
default {
no match, take some default action?
}
}
}