Forum Discussion
Robert_47833
Nov 14, 2011Altostratus
how 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" - "*gif" - "*png" - "*img" - "*ico" - "*js" - "*css" - "*swf" - "*swz" - "*vbs" - "*html" - "*htm" - "*csv" - "*txt" - "*crossdomain.xml" {pool xyz}
in this case,should I create a variable uri to replace [HTTP::path] to make the irule more efficent?
- nitassEmployeein this case ,I can save the output of HTTP::path to a variable,right? because I run [HTTP::path] 3 times
- Robert_47833Altostratushmm,can u show me in which case I should use variable to make it more efficent?
- nitassEmployeecan u show me in which case I should use variable to make it more efficent?it is in 6 - Use Variables which you have mentioned.
- Robert_47833Altostratusin my case,it is like 6
- nitassEmployeeit is like 5 rather than 6.
- Robert_47833Altostratushmm,I am a little confused
- nitassEmployeeso if I use [string tolower [HTTP::uri]] many times,then,I need to use variable
- hooleylistCirrostratusThe 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.
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 } } } } } }
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 } } } } } }
- Robert_47833Altostratusahhhh
- Robert_47833AltostratusHi,Aaron
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