Forum Discussion
disable ram cache while when get http error codes
I have the below irule code but I also want to disable the ram cache feature when a backend server returned a http error codes (404, 303... ) to clients.So how can I need to update the rule to accomplish my goal.?
Thank you,
rule cache_rule3
{
when HTTP_REQUEST {
if { [ class
match [HTTP::path] starts_with cache_obj] } {
CACHE::enable
log local0.
"Caching [HTTP::path]"
} else {
log local0.
"NON Caching [HTTP::path]"
CACHE::disable
log local0.
"Non Caching [HTTP::path]"
}
- hooleylistCirrostratusHi Emre,
when HTTP_REQUEST { set uri [HTTP::uri] if { [ class match [HTTP::path] starts_with cache_obj] } { CACHE::enable log local0. "Caching [HTTP::path]" } else { log local0. "NON Caching [HTTP::path]" CACHE::disable } } when HTTP_RESPONSE { Check the response status code switch [HTTP::status] { 404 - 500 - 503 { CACHE::disable log local0. "Disabled cache for [HTTP::status] response to $uri" } default { CACHE::enable log local0. "Enabled cache for [HTTP::status] response to $uri" } } }
when HTTP_REQUEST { set uri [HTTP::uri] if { [ class match [HTTP::path] starts_with cache_obj] } { CACHE::enable log local0. "Caching [HTTP::path]" } else { log local0. "NON Caching [HTTP::path]" CACHE::disable } } when HTTP_RESPONSE { Check the response status code switch [HTTP::status] { 200 - 301 - 302 { CACHE::enable log local0. "Enabled cache for [HTTP::status] response to $uri" } default { CACHE::disable log local0. "Disabled cache for [HTTP::status] response to $uri" } } }
- Emre_27149Nimbostratus
Hi Aaron,
Thank you so much for your interest and quick response.
Kindly..
- Scott_HopkinsNimbostratus
I know this is digging up a really old post, but one caveat on hoolio's second recommendation:
If you wanted to enable caching only for 200, 301, 302, etc responses, you could flip the CACHE::enable/disable statements:
> when HTTP_REQUEST { > > set uri [HTTP::uri] > > if { [ class match [HTTP::path] starts_with cache_obj] } { > > CACHE::enable > log local0. "Caching [HTTP::path]" > > } else { > > log local0. "NON Caching [HTTP::path]" > CACHE::disable > } > } > when HTTP_RESPONSE { > > Check the response status code > switch [HTTP::status] { > > 200 - > 301 - > 302 { > CACHE::enable > log local0. "Enabled cache for [HTTP::status] response to $uri" > } > default { > CACHE::disable > log local0. "Disabled cache for [HTTP::status] response to $uri" > } > } > }
Without 304 in the 'CACHE::enable' half of the switch statement in the HTTP_RESPONSE event, RAMCache doesn't properly catch responses from the originating web server on checks for expired objects (at least on 10.2.4 HF3).
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