Forum Discussion

dan_6764's avatar
dan_6764
Icon for Nimbostratus rankNimbostratus
Jul 14, 2009

Caching issue

Hi,

 

 

I am running version 10.0.0 on my LTM. I wish to be able to flush certain items from my cache dependant on file type/age etc..

 

 

I have written the rule below but it doesn't work %100.

 

 

Basically it will flush only 1 item at a time..

 

 

Eg

 

I request the page and I cache 2 items on the LTM : 1 gif & 1 jpg

 

 

If I wait 10 seconds and request a new page the jpg will flush.

 

If I wait another 10 seconds and request a new page the gif will flush.

 

 

However, if I request the page and wait 25 seconds (passing the cache age rule for both the gif & jpg) only the jpg gets flushed.

 

 

when RULE_INIT {

 

set ::10_secs 10

 

set ::20_secs 20

 

set ::one_day 86400

 

set ::two_hours 7200

 

set ::one_week 604800

 

 

}

 

 

when HTTP_REQUEST {

 

set requested_uri [HTTP::uri]

 

}

 

when HTTP_RESPONSE {

 

if { $requested_uri ends_with ".jpg" } {

 

} elseif { $requested_uri ends_with ".gif" } {

 

CACHE::enable

 

} else

 

{ CACHE::disable }

 

}

 

 

 

when CACHE_REQUEST {

 

if { [CACHE::age] > $::10_secs and $requested_uri ends_with ".jpg"} {

 

CACHE::expire

 

log local0. "Expiring content: Age > 10 seconds * jpg"

 

} elseif { [CACHE::age] > $::20_secs and $requested_uri ends_with ".gif"} {

 

CACHE::expire

 

log local0. "Expiring content: Age > 20 seconds * gif"

 

}

 

}

 

 

 

 

Can anybody help??

 

 

Thanks

 

Dan
  • ok.. think i have cracked it... unless anyone can see something I am missing

     

     

     

    hen RULE_INIT {

     

    set ::10_secs 10

     

    set ::20_secs 20

     

    set ::one_day 86400

     

    set ::two_hours 7200

     

    set ::one_week 604800

     

     

     

    }

     

     

    when HTTP_REQUEST {

     

    set requested_uri [HTTP::uri]

     

    }

     

    when HTTP_RESPONSE {

     

    if { $requested_uri ends_with ".jpg" } {

     

    } elseif { $requested_uri ends_with ".gif" } {

     

    CACHE::enable

     

     

    } else

     

    { CACHE::disable

     

    }

     

     

    }

     

     

     

     

    when CACHE_REQUEST {

     

    if { ([CACHE::age] > $::10_secs and $requested_uri ends_with ".jpg") or ([CACHE::age] > $::20_secs and $requested_uri ends_with ".gif") } {

     

    CACHE::expire

     

    log local0. "Expiring content: Age > x seconds & $requested_uri "

     

    }

     

    }
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    The logic in the CACHE_REQUEST portion in your second rule looks much more sound. Rather than only expiring the first match, it'll expire based on either match.

     

     

    I think you could probably re-write the HTTP_REQUEST portion though. If you don't want to do anything when a jpg comes through, you could remove that comparison and use a logical not with the gif statement to achieve the same thing.

     

     

    Colin