Forum Discussion
rodrigo_Benzaqu
Nimbostratus
May 20, 2009Help to tune an Irule
Hi Guys, I have this rule to match contents on my site.
I want to simplify the rule to avoid extra cpu cycles.
rule Cache_fetch {
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/jm/pms*" -
"/cgi/pms/*" {
pool PMS_java
}
"/jm/searchXml*" {
pool POOL_XML
}
"/jm/img?*" {
pool IMG_POOL
}
"/jm/search?*" {
pool POOL_NOWWW
}
"/jm/item?*" {
pool POOL_ARTICULO_WS
}
"/jm/profile?*" {
pool POOL_NOWWW
}
"/jm/ml.track.me*" {
pool POOL_TRACK_CNT
}
"/jm/ploader*" {
pool POOL_PLOADER
}
"/jm/syi4picloader*" {
pool POOL_PLOADER
}
"/jm/ml.syi4.expic.*" {
pool POOL_EXPIC
}
"*_PA" {
pool POOL_reg
}
"/jm/*" -
"/jms/*" -
"/servlet/*" -
"/dwr/*" {
pool Java_Servers
}
"*/ml/*" {
pool SQL_Servers
}
default {
pool static_server
}
}
}
}
I made this changes , what do you think? is possible to do /jm/*earch*/
rule Cache_fetch {
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/jm/pms*" -
"/cgi/pms/*" {
pool PMS_java
}
"/jm/*earchXml*" {
pool POOL_XML
}
"/jm/img?*" {
pool IMG_POOL
}
"/jm/search?*" - "/jm/profile?*" {
pool POOL_NOWWW
}
"/jm/item?*" {
pool POOL_ARTICULO_WS
}
"/jm/ml.track.me*" {
pool POOL_TRACK_CNT
}
"/jm/*loader*" - "/jm/syi4picloader*" {
pool POOL_PLOADER
}
"/jm/ml.syi4.expic.*" {
pool POOL_EXPIC
}
"*_PA" {
pool POOL_reg
}
"/jm/*" -
"/jms/*" -
"/servlet/*" -
"/dwr/*" {
pool Java_Servers
}
"*/ml/*" {
pool SQL_Servers
}
default {
pool static_server
}
}
}
}
Thanks
Rodrigo
- The_Bhattman
Nimbostratus
I don't if this speeds up anything but you could do a "return" after it has selected the pool such that it immediately exists when it finds a match. - hoolio
Cirrostratus
I'm pretty sure that the switch is already exited after the first match is found. If you don't need to check the query string in the URI, you could change HTTP::uri to HTTP::path so that you're only evaluating the requested object. It's shorter and should be more efficient than the full URI.
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