Forum Discussion
smp_86112
Cirrostratus
Jun 24, 2010Optimizing If statement conditions
I see this examples like this all over the place:
when HTTP_REQUEST {
if { [HTTP::host] equals "www.myhost.com" and [HTTP::uri] equals "/myuri" } {
HTTP::redirect https://[HTTP::host][HTTP::...
smp_86112
Cirrostratus
Jun 28, 2010Yes, both Jason and hoolio bring up points I didn't consider. It seems this consolidation idea is only useful in pretty limited circumstances. Here are the results of my testing when forcing the string to lowercase (sorry for the long delay). It seems that adding the string tolower statement reversed the results. Does that make sense to you?
timing on
when HTTP_REQUEST {
if { [string tolower [HTTP::host][HTTP::uri]] equals "www.myhost.com/admin" } {
HTTP::uri "/new_uri"
}
}
ltm rule-event {
aborts 0
avg-cycles 14762
event-type HTTP_REQUEST
failures 0
max-cycles 146684
min-cycles 0
name www.myhost.com
priority 500
total-executions 100017
}
ltm rule-event {
aborts 0
avg-cycles 14892
event-type HTTP_REQUEST
failures 0
max-cycles 121975
min-cycles 0
name www.myhost.com
priority 500
total-executions 100010
}
ltm rule-event {
aborts 0
avg-cycles 14804
event-type HTTP_REQUEST
failures 0
max-cycles 160099
min-cycles 0
name www.myhost.com
priority 500
total-executions 100014
}
timing on
when HTTP_REQUEST {
if { [HTTP::host] equals "www.myhost.com" and [string tolower [HTTP::uri]] equals "/admin" } {
HTTP::uri "/new_uri"
}
}
ltm rule-event {
aborts 0
avg-cycles 14466
event-type HTTP_REQUEST
failures 0
max-cycles 89955
min-cycles 0
name www.myhost.com
priority 500
total-executions 100014
}
ltm rule-event {
aborts 0
avg-cycles 14457
event-type HTTP_REQUEST
failures 0
max-cycles 129122
min-cycles 0
name www.myhost.com
priority 500
total-executions 100020
}
ltm rule-event {
aborts 0
avg-cycles 14129
event-type HTTP_REQUEST
failures 0
max-cycles 156109
min-cycles 0
name www.myhost.com
priority 500
total-executions 100021
}Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
