David_Patino_20
May 04, 2012Nimbostratus
Instructing 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::expire.
It's sort of working, I can't seem to pin down the proper order of operations.
Here's what I have so far:
when HTTP_REQUEST {
Disable cache for a defined set of folders
if { [class match [HTTP::uri] contains folders_to_not_cache] }{
CACHE::disable
return
}
if { [string tolower [HTTP::uri]] contains "?expire" } {
log "Request to expire [getfield [string tolower [HTTP::uri]] "?expire" 1] received."
set expire_cache_trigger 1
HTTP::redirect "http://[HTTP::host][getfield [string tolower [HTTP::uri]] "?expire" 1]"
}
}
when CACHE_REQUEST {
if { ( [info exists expire_cache_trigger] ) && ( $expire_cache_trigger==1 ) } {
CACHE::expire
log "Cache Expired"
unset expire_cache_trigger
}
}
When I try this command on a system that's local to the external interface of the unit, it works.Log output sample:
May 4 14:10:58 local/tmm info tmm[4853]: 01220002:6: Rule iRule-Cache-Processing : Request to expire /test.html received. May 4 14:10:58 local/tmm info tmm[4853]: 01220002:6: Rule iRule-Cache-Processing : Cache Expired
And indeed doing a tmsh show profile ramcache uri /test.html shows that the 'received' and 'expires' timestamps have updated.
However, if I execute a url?expire from a remote site the variable is no longer set when CACHE_REQUEST runs, so the actual CACHE::expire command never executes.
I've tried running the CACHE::expire inside the CACHE_RESPONSE event, but at that time it seems to have no effect. The command produces no errors in the log, but when viewing the cache details for the URI the received and expire timestamps do not update.
Any thoughts?
thanks.
David