Forum Discussion
David_Patino_20
Nimbostratus
May 04, 2012Instructing BigIP to expire RAM Cache when it receives a URL Query
Howdy Everyone.
I've an issue I've been working on.
I'm trying to develop a irule that will check the URI::query for an expire entry. If it finds one, it will instruct the system to do a CACHE...
Caleb_ISC_13156
Nimbostratus
May 16, 2012UPDATE:
Below is the updated iRule and a few logs. Basically when a page is modified by an author and then saved, a single request is made to the uri with 'expire' added as a query: uri?expire
The goal is that when the F5 receives the uri?expire it will completely remove the uri from it's existing ram cache and grab the newly updated uri which it will then cache.
What is happening instead is that the F5 continues to serve the old version of the uri that it was supposed to have cleared.
We did a test where we:
1. Updated and saved a page with the content: TEST 1
2. Verified it saved correctly and was being served correctly by accessing the server locally and bypassing the F5
3. Manually requested the URI with uri?expire
4. Used a browser in private mode by deleting all cookies and cache, then requesting the uri to look if the content showed TEST 1
We repeated this process incrementally by repeating the steps above and incrementing the TEST number. What we found in say TEST 4 was that the F5 would sometimes show TEST 3, and even sometimes show TEST 2, but never showed TEST 4.
We could occasionally see the updated version of the uri by requesting uri?expire= or uri?expire?expire
Here are some logs:
13:03:16 tmm1[5121]: 01220002:6: Rule iRule-Cache-Processing : Request to expire /anything/ received from x.x.x.x.
13:03:16 tmm1[5121]: 01220002:6: Rule iRule-Cache-Processing : Cache Expired
13:03:18 tmm1[5121]: 01220002:6: Rule iRule-Cache-Processing : Request to expire /anything/ received from x.x.x.x.
13:03:18 tmm1[5121]: 01220002:6: Rule iRule-Cache-Processing : Cache Expired
13:03:27 tmm1[5121]: 01220002:6: Rule iRule-Cache-Processing : Request to expire /anything/ received from x.x.x.x.
13:03:27 tmm1[5121]: 01220002:6: Rule iRule-Cache-Processing : Cache Expired
And here is the iRule.
iRule-Cache-Processing
when HTTP_REQUEST {
If the URL contains a folder that we're not supposed to cache, disable the cache
if { [class match [HTTP::uri] contains folders_to_not_cache] }{
CACHE::disable
return
} else {
Ignore any cache-control headers sent by the user's browser.
if { [HTTP::header exists "Cache-Control"] } { HTTP::header remove "Cache-Control" }
Turn on caching
CACHE::enable
}
Convert the query options to lower case, then look for "expire" in them
if { [string tolower [HTTP::query]] ends_with "expire" } {
If we found the request, make sure it's coming from a valid admin IP
if { [class match [client_addr] equals admin_ips] } {
If it's a valid source, then log the request and set the variable to flag the cache to be expired in the CACHE_REQUEST event.
log "Request to expire [getfield [string tolower [HTTP::uri]] "?expire" 1] received from [client_addr]."
log local0. "URI Rule Hit"
Adding next line to force next request to web1 for when cache is reloaded
pool [LB::server pool] member x.x.x.x 80
set expire_cache_trigger 1
HTTP::uri [string range [HTTP::uri] 0 end-7]
} else {
If request was not from a valid source, log the attempt
log "Received expire cache directive from non-admin IP [client_addr], ignoring"
redirect them to the page without the expire command.
HTTP::uri [string range [HTTP::uri] 0 end-7]
}
}
}
when CACHE_REQUEST {
Check if the variable has been set instructing this event to expire the cache
if { ( [info exists expire_cache_trigger] ) && ( $expire_cache_trigger ne "" ) } {
CACHE::expire
log "Cache Expired"
Unset the variable so we don't keep calling this function needlessly
unset expire_cache_trigger
}
}
Any ideas?
Thanks,
Caleb
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects