Forum Discussion

pjcampbell_7243's avatar
Mar 17, 2011

jsp request making it to image pool

Every once in a while a jsp request is making it to our image pool. I have never seen this before. we have been using the following iRule for a few years. We just setup another website using the same iRule.

Here is the irule:

when CLIENT_ACCEPTED {

Save default pool name

set default_pool [LB::server pool]

}

when HTTP_REQUEST {

if { [HTTP::path] ends_with ".jpg" }{

pool images.xxx.com

} elseif { [HTTP::path] ends_with ".gif" }{

pool images.xxx.com

} elseif { [HTTP::path] ends_with ".png" }{

pool images.xxx.com

}

}

Would the following fix the problem (see "else"):

when CLIENT_ACCEPTED {

Save default pool name

set default_pool [LB::server pool]

}

when HTTP_REQUEST {

if { [HTTP::path] ends_with ".jpg" }{

pool images.xxx.com

} elseif { [HTTP::path] ends_with ".gif" }{

pool images.xxx.com

} elseif { [HTTP::path] ends_with ".png" }{

pool images.xxx.com

} else {

pool $default_pool

}

}

one thing to mention is that we have multiple websites with different pools using the same iRule so, we need to make sure we don't accidently send requests for one site to another site.

BTW, sounds like I could make this a bit more efficient with the following? (what is switch -glob vs regular old switch?)

when CLIENT_ACCEPTED {

Save default pool name

set default_pool [LB::server pool]

}

when HTTP_REQUEST {
  switch -glob [HTTP::path] {
    *.png { pool images.xxx.com }
    *.jpg { pool images.xxx.com }
    *.gif { pool images.xxx.com }
    default { pool $default_pool }
  }
}

  • Hi pjcampbell,

     

    -glob argument allows you to match string to the patterns, which is exactly what you are doing the switch code that you posted.

     

     

    Your code looks fine so it should work.

     

     

    Bhattman