Forum Discussion

rodrigo_Benzaqu's avatar
rodrigo_Benzaqu
Icon for Nimbostratus rankNimbostratus
May 20, 2009

Help 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
  • 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's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    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.

     

     

    If you do stick with HTTP::uri and you're looking for a literal question mark, you should escape the ? with two backslashes. Else, when using the -glob flag the question mark is interpreted as any single character:

     

     

    % string match test? "test1"

     

    1

     

    % string match test\? "test1"

     

    1

     

    % string match test\\? "test1"

     

    0

     

    % string match test\\? "test?"

     

    1

     

     

    Aaron