The Rewrite feature of the NetScaler can be used to automatically retry a web site when the backend server responds to a request with a 500 error.
Summary
In this example the rewrite feature will take 500 and replace them with a 302 (to the original URL) and redirect the connection up to 5 times, in hopes that the connection gets directed to a functioning web server on the backend.
Code Snippet
add rewrite action retry_request replace_http_res "\"HTTP/1.1 302 Temporary Redirect\\r\\nLocation:
http:retry=\"+http.req.cookie.value(\"retry\").typecast_num_t(DECIMAL).add(1)+\"\\r\\n\\r\\n<html>Temporary Error, retry</html>\""
add rewrite policy is_500 "http.res.status.eq(500) && http.req.cookie.value(\"retry\").typecast_num_t(decimal).le(5)" retry_request
bind rewrite global is_500 10 END -type RES_DEFAULT
More Information
It will be very helpful if you can explain what each line of the above code accomplishes.