Forum Discussion

Simon_Chan_1115's avatar
Simon_Chan_1115
Icon for Nimbostratus rankNimbostratus
Jul 04, 2007

irule for handling jpg, bmp request

Hi,

 

 

we want to use other new pool or servers for handling static page request such as .jpg, bmp, mp3 etc.

 

 

and now we already had the following irule running:

 

 

when CLIENT_ACCEPTED {

 

set add_persist 1

 

}

 

when HTTP_RESPONSE {

 

if { [HTTP::cookie exists "JSESSIONID"] and $add_persist } {

 

persist add uie [HTTP::cookie "JSESSIONID"]

 

set add_persist 0

 

}

 

}

 

when HTTP_REQUEST {

 

if { [HTTP::cookie exists "JSESSIONID"] } {

 

persist uie [HTTP::cookie "JSESSIONID"]

 

} else {

 

set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"]

 

if { $jsess != "" } {

 

persist uie $jsess

 

}

 

}

 

}

 

 

anyone know if we want to pass static request to other servers/pool, what we can to modify?

 

 

Regards

 

 

Simon.

1 Reply

  • I'm assuming you don't need persistence for the static files. If so, something like this should work (assuming you don't care about persistence on the static requests...

    when CLIENT_ACCEPTED {
      set add_persist 1
    }
    when HTTP_RESPONSE {
      if { [HTTP::cookie exists "JSESSIONID"] and $add_persist } {
        persist add uie [HTTP::cookie "JSESSIONID"]
        set add_persist 0
      }
    }
    when HTTP_REQUEST {
      switch -glob [string tolower [HTTP::uri]] {
        "*.jpg" -
        "*.bmp" -
        "*.mp3" {
          pool static_pool
        }
        default {
          if { [HTTP::cookie exists "JSESSIONID"] } {
            persist uie [HTTP::cookie "JSESSIONID"]
          } else {
            set jsess [findstr [HTTP::uri] "jsessionid" 11 ";"]
            if { $jsess != "" } {
              persist uie $jsess
          }
        }
      }
    }

    Basically what this does is for all requests ending with ".jpg", ".bmp", or ".mp3", assign the traffic to the static_pool. All other requests will default back to your original logic.

    -Joe