Forum Discussion
Emre_27149
May 03, 2011Nimbostratus
disable ram cache while when get http error codes
Hi All, 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 t...
Scott_Hopkins
Nov 15, 2013Nimbostratus
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
DevCentral Quicklinks
* 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
Discover DevCentral Connects