Forum Discussion
I'm trying to create an irule that will quickly redirect traffic that meets a URI and IP address list and send them to an ifile.
The rule works but it is slow to push traffic to the page about 45 seconds and some browsers are caching the page and not coming back to the original page when rule is removed. What is the best way interrupt sessions to launch the page and also keep browsers from caching my ifile so they come back with just a refresh? I have two data groups. one has a list of internal IP addresses and one has a list of URLs that I want to re-direct traffic if they match. This kind of works but it could use some help with controlling the cache.
Thank in advance!
when HTTP_REQUEST {
set net_code [class match -value -- [IP::client_addr] equals internal_network_dg]
set app_path [class match -value -- [string tolower [HTTP::path]] starts_with maintenance-page-path-dg]
if {$app_path eq "m" and $net_code ne "r"} {
HTTP::respond 302 content [ifile get HighTraffic.html] "Content-Type" "text/html" { HTTP::header replace "Cache-Control" "max-age=10,post-check=50,pre-check=200" } }
}
- JG
Cumulonimbus
Not sure what the performance issue is related to, but did you have large dg files?
The following will solve the caching issue for you:
when HTTP_REQUEST { set net_code [class match -value -- [IP::client_addr] equals internal_network_dg] set app_path [class match -value -- [string tolower [HTTP::path]] starts_with maintenance-page-path-dg] set mytime [clock seconds] set last_modified "[clock format $mytime -format {%a, %d %b %Y %T %Z} -gmt 1]" set cache_control_1 "no-store, no-cache, must-revalidate, max-age=0" set cache_control_2 "post-check=0, pre-check=0, false" set pragma "no-cache" if {$app_path eq "m" and $net_code ne "r"} { HTTP::respond 200 content [ifile get HighTraffic.html] "Content-Type" "text/html" "Last-Modified" $last_modified "Cache-Control" $cache_control_1 "Cache-Control" $cache_control_2 "Pragma" $pragma Connection close } }
.[Edited]
- jcline
Nimbostratus
Thanks for the reply JG.
Your rule didn't work for me. I was able to get the cache working a little better with the rule below.
My biggest problem now is I have test clients running Chrome that have a session to the resource and are unwilling to give it up and take my iFile page.
This one has the best response for caching the ifile for me but it's still not what I'd like it to be on all browsers. IE works perfect but Chrome loves its cache and likes to keep it's sessions opened.
when HTTP_REQUEST { set net_code [class match -value -- [IP::client_addr] equals internal_network_dg] set app_path [class match -value -- [string tolower [HTTP::path]] starts_with maintenance-page-path-dg] if {$app_path eq "m" and $net_code ne "r"} { HTTP::respond 307 content [ifile get HighTraffic.html] "Content-Type" "text/html" { HTTP::header replace "Cache-Control: max-age=0, no-cache" } } }
- JG
Cumulonimbus
Not exactly sure of your situation, and I cannot find any F5 documentation supporting the syntax you are using here.
If you are referring to an _established_ connection failing to receive the sorry page your irule is triggered to provide, you might need to apply a "OneConnect" profile to your virtual server, which will process all requests in a connection and not just at the start of a connection as otherwise would be the case.
- jcline
Nimbostratus
I am trying to get established connections to trigger on the irule and get the sorry page. I'm not sure how to force the clients to reconnect so they run the rule. I haven't had good luck with oneconnect in the past. I tried it based on your suggestion but it didn't work. I've thought about trying to see if there is a uei record and deleting it or setting it to NULL but haven't had any luck. Probably because it's not recommended.
- JG
Cumulonimbus
It would be very odd if the irule is not applied to each request if oneconnect is applied.
You might want to put in some logging to prove that this is the case.
- jcline
Nimbostratus
JG, Thanks so much for your attempts and attention. I have a work around for now. The problem is mostly with Chrome not wanting to relinquish the session. I'm going to use a sledge hammer where I was hoping to have a screw driver. I have found that if I go to the console and use tmsh commands I can delete all of the sessions from one server at a time and force them to run through the irule when the reconnect. It is what it is until I figure out how to get Chrome to play nice.
Edge does as it's told pretty quickly.
Thanks Again!
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com