Kris__109062
Sep 25, 2012Nimbostratus
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
}
}
}