Ram Cache

Is it possible to make my Ram Cache “selective” using iRule just like Compression?

Yes there are a few ways of doing this. If you know what resources need to be excluded based on their URI, you can add them to the cache exclude list (no rule required). NOTE: the exclude list accepts regular expressions.

If your exclusion is a little bit more complex, you can use the ‘CACHE::disable’ during the HTTP_REQUEST and HTTP_RESPONSE events to dynamically disable caching.

I think this rule might be what you are looking for.

class images  {
   ".bmp"
   ".gif"
   ".jpg"
}
when HTTP_REQUEST {
    if { [matchclass [HTTP::uri] ends_with $::images]} {
         CACHE::enable
    }
    else {
         CACHE::disable
    }
}

I’m new to RAM Cache as well but as I see it from the docs:

>Is it the CACHE::expire will expire all the content in the RAM cache?

CACHE::expire only expires (revalidates) the URI you are working with at the time.

>If I use include list, the others will be exclusive?

No, it will however include URL’s that would otherwise have been excluded. “When you add URIs to the include list, the GET methods are cached for the URI and other methods, including non HTTP methods”

>If I use exclude list, the othere will be inclusive?

Again I don’t think so, no. It’s excludes URIs that would otherwise be cached by default.

>What is the PIN list? I cannot find document on that so far.

According to the help in the web interface:

Pin List: Lists the URIs that the system retains indefinitely in the RAM cache.

BTW there’s a PDF about RAM Cache here: http://tech.f5.com/home/bigip-next/solutions/traffic/ramcache.pdf

I have static content that i serve from pools other than the default for the virtual server.

While I don’t cache from the virtual server itself, I would like to use the RAM Cache for the pages that are being requested from these static content pools.

I tried the command “CACHE::enable” before the “pool static_pool” command, however when applied it did not serve up any images from the static servers.

I would hope it would be possible to ask it to cache (and serve) those pages from RAM Cache, but I’m guessing I just don’t understand how to selectively enable it from the iRule.

Any insights would be _greatly_ appreciated.

Hi brad,

did you get an answer to your question.

I want to do something similar, I want to apply caching to one pool but not the other, I have an i rule choosing the pool and the VS does not have caching enabled. Should I enable caching on the VS and disable it for the pool that I don’t want caching in?

Thanks.

Rab.

Hi Rab,

I’d suggest enabling RAM caching on a custom HTTP profile you add to the virtual server and then disable caching in the same iRule when the pool you don’t want caching enabled for is selected. You can use the CACHE::disable command to do this:

http://devcentral.f5.com/wiki/default.aspx/iRules/CACHE\_\_enable.html

Aaron

Thanks Aaron that looks like it works.

Is it possible to check if the http profile has caching enabled, if I use CACHE::disable when it is not set in the profile I get an error -

Operation not supported (line 1) invoked from within “CACHE::disable”

I want the same rule to work if http profile has or has not caching enabled.

Thanks.

Rab.

This is what I needed -

if { [PROFILE::http ramcache] equals 1 } {

CACHE::disable

}

Hi Rab,

I missed your reply. Glad you figured this out.

Aaron

Just on this issue of the RAM Cache…if I need to disable caching for an entire domain, is it enough to just add the domain to the URI’s Exclude List or do I need to add a wildcard masks to the end of it.

Eg: I want to exclude the following from being cached:

- abc.xyz.com

- abc.xyz.com/blah.jpg

- abc.xyz.com/new/12345

- etc

What to add to the URI Exclude list:

abc.xyz.com <-- is this enough???

abc.xyz.com/* <-- or do I need something like this??

Thanks.

Andy

Hi hc_andy,

Depending on how you are implementing the search, you may or may not need to use the Wildcard Qualifier.

So in the first iRule you might have something like this where you would need it, or in the second iRule you would not:

when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"*.abc.xyz.com/*" { CACHE::disable }
"*.foo.com/*" { pool foo.pool }
}
}when HTTP_REQUEST {
if { [HTTP::host] contains "abc.xyz.com" } {
CACHE::disable
}
else { pool server.pool }
}

Hope this helps.