Forum Discussion
My RAM Cache Irule
Hi,
Given the following irule and http profile with ram cache enabled and applied to a VS, why would I still be seeing a lot of occurences to the backend servers of clients GETing the URI when they meet all the caching criteria?
I can see the cache is getting hits with "bigpipe profile http http_cache ramcache entry all show"
The Ram Cache http profie has no pinned/included/exluded URI's - it is simply enabled with default values, however my irule below makes sure only the URI's I want are cached.
profile http http_cache {
defaults from http
ramcache enable
ramcache size 100mb
ramcache max entries 10000
ramcache max age 600
ramcache min object size 600
ramcache max object size 50000
ramcache ignore client cache control all
ramcache aging rate 1
ramcache insert age header disable
ramcache uri exclude none
ramcache uri include none
ramcache uri pinned none
}
class cache_uris {
"/path/to/some/uri?category=blah"
}
when RULE_INIT {
set ::objectsize 500
}
when HTTP_REQUEST {
set seenuri 0
if { [matchclass [HTTP::uri] equals $::cache_uris] } {
log local0. "[HTTP::uri] matched caching criteria. Set seenuri to true for http_response even to cache."
set seenuri 1
}
}
when HTTP_RESPONSE {
by default cache nothing.
CACHE::disable
if { $seenuri equals 1 } {
set var_content_encoding [string tolower [HTTP::header "Content-Encoding"]]
set var_content_length [HTTP::header "Content-Length"]
cache the URI only if its gzipped and exceeds 500 bytes
if { $var_content_encoding contains "gzip" && $var_content_length > $::objectsize } {
CACHE::enable
}
}
}
- Mohamed_Lrhazi
Altocumulus
To me the algorithms for deciding whether a URL is cachable or not are, what you call it, black magic? or voodoo? - Mohamed_Lrhazi
Altocumulus
It might well be that a query string in the URI qualifies it as uncachable: http://dcommon.bu.edu/xmlui/bitstream/handle/2144/1812/2000-019-web-cachability.pdf?sequence=1 - Kris__109062
Nimbostratus
its definately cached query string and all and receiving hits from clients (ie. the F5 is serving them from the cache.. but not always..) - Mohamed_Lrhazi
Altocumulus
You could try capturing the full headers of an object you think ought to be cached and was not, and then ask, why what this one not cached? - Kris__109062
Nimbostratus
Thanks I may do. The headers are all uniform because they come from a mobile app that we developed, hence we know everything that hits this URI is identical. - Michael_Yates
Nimbostratus
Hi VirginBlue Kris, - Kris__109062
Nimbostratus
Good idea..
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