Forum Discussion

shinchan-f5's avatar
Apr 13, 2020

Irule optimization

Trying to redirect connection if response status code is 404 and the requested http uri contains list of uri's provided in the datagroup.

It worked well as far as the requirement was concerned. But it is utilizing much of the memory owing to which have to take the irule off.

Below is the irule. Need help to optimize it so as to decrease the CPU resource.

 

when CLIENT_ACCEPTED {

set req 0

}

 

when HTTP_REQUEST {

 set http_request [HTTP::request]

 if {$req eq 1 && [class match [HTTP::uri] contains "url"]}{

   HTTP::redirect "http://191.168.10.20/xyz/"

   set req 0

}}

 

when HTTP_RESPONSE timing off {

 if { [HTTP::status] == 404}{

set req 1

HTTP::retry $http_request

}}

2 Replies

  • Prepared the iRule based on the hints provided in question. You can validate and let us know the result.

    when HTTP_REQUEST { 
          set url_http [HTTP::uri] 
     } 
     when HTTP_RESPONSE { 
        if { ([HTTP::status] == 404) && ( $url_http contains "url") } { 
                  HTTP::respond 302 Location "http://191.168.10.20/xyz/"
        } 
     } 

    Hope it will work.