Forum Discussion
Robert_47833
Altostratus
Nov 14, 2011how to use switch to match datagroup
1:there is a datagroup:cjj
how to use switch to match this group
switch -glob [HTTP::path] {
"cjj" xxxx ???
2:
switch -glob [HTTP::path] { "*jpg" - "*bmp" - ...
hoolio
Cirrostratus
Nov 17, 2011The value for [HTTP::path] is cached in memory the first time the command is run. However, if you perform an operation on the path, like [string tolower [HTTP::path]] that output is not cached. So in your example, if you're running [HTTP::path] multiple times, it's better to not save the value to a variable.
If you were checking the path set to lower case in multiple locations in the iRule, it would be more efficient to save the value to a variable versus running string tolower more than once.
Here are examples of the two different scenarios. I hope this is clearer for you.
Example using no variable as [HTTP::path] is cached:
switch -glob [HTTP::path] {
"*gif" -
"*png" {
switch -glob [HTTP::path] {
"/static.*" -
"/s.*" {
switch -glob [HTTP::path] {
"*cswebtool*" -
"*cobrands*" {
persist none
pool SRWD52-STATIC
return
}
}
}
}
}
}Or
Example using a variable as [string tolower [HTTP::path]] is not cached:
set path [string tolower [HTTP::path]]
switch -glob $path {
"*gif" -
"*png" {
switch -glob $path {
"/static.*" -
"/s.*" {
switch -glob $path {
"*cswebtool*" -
"*cobrands*" {
persist none
pool SRWD52-STATIC
return
}
}
}
}
}
}Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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