CodeShare
Have some code. Share some code.
cancel
Showing results for 
Search instead for 
Did you mean: 
Patrick_Chang_7
Historic F5 Account

Problem this snippet solves:

An iRule to convert an HTTP 404 response to a blank 200 response. HTTP 404 responses cannot be cached and will always hit your back end infrastructure. If you are using a proxy/cache for your web application, you can convert the HTTP 404 response to a blank 200 response that can be cached. This can be useful for reducing the load on your back end if you have a web site which is always under construction. It can also help mitigate one type of denial of service attack.

Code :

# iRule to replicate no 404s
when HTTP_REQUEST {
  # Don't allow data to be chunked
  if { [HTTP::version] eq "1.1" } {
    if { [HTTP::header is_keepalive] } {
      HTTP::header replace "Connection" "Keep-Alive"
    }
     HTTP::version "1.0"
  }
}
when HTTP_RESPONSE {
   # grab response of a 404
   if {[HTTP::status] == 404}{
      HTTP::collect [HTTP::header Content-Length]
   }
}

when HTTP_RESPONSE_DATA {
   # change response to 200 and send
   HTTP::respond 200 content [HTTP::payload]
}
Version history
Last update:
‎17-Mar-2015 12:19
Updated by:
Contributors