Forum Discussion
iRule error optimization
Hi,
For the iRule guru's, i am looking on a way to optimize this iRule which fails saying that the else is not accepted at the end.
Can I do a IF with inside a SWITCH and then a HTTP::redirect in the ELSE? Any way to optimize this, as it is going to be run many times (>100k users).
Thanks!
when HTTP_REQUEST {
if { [active_members [LB::server pool]] > 0 } {
switch -glob [string tolower [HTTP::host]] {
"one.example.com*"
{
if { not ([HTTP::uri] starts_with "/_markethome.aspx?")} {
HTTP::redirect http://[HTTP::host]/_markethome.aspx?[HTTP::uri]
return
}
}
"nceforleaders*"
{
HTTP::redirect http://theother.example.com/index.html
return
}
default { return }
}
else {
HTTP::redirect http://globe.example.com
return
}
}}
2 Replies
or better do this way
when HTTP_REQUEST { IF [active_members [LB::server pool]] == 0 } { do redirect to last resource} switch -glob [string tolower [HTTP::host]] { "one.example.com*" -.... "two.example.com*" -.... }- Kevin_Stewart
Employee
This actually looks pretty solid. It's going to run exactly one time for each HTTP request times the total number of HTTP requests from all users over some given amount of time. That's not a bad thing. The order that you're placing these is marginally important for such a small iRule. For anything substantially larger, I'd recommend putting more prevalent conditions closer to the top.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
