Forum Discussion

Phil_53695's avatar
Phil_53695
Icon for Nimbostratus rankNimbostratus
Aug 18, 2011

Cache hits show 0 on irule when looking at ltm log

Hi,

 

 

Below is an irule that I am trying to debug to see if indeed the URI(s) file types get cached and nothing else.

 

From viewing the ltm log, I see:

 

 

: 0 cache hits /Public/Legal/img/foot_back_bot.png

 

 

So I assume my syntax must be off since it "should" be caching the .png as per my irule.

 

 

 

 

when HTTP_REQUEST {

 

set debug 1

 

set foundmatch 0

 

if { ([HTTP::uri] contains ".swf") or ([HTTP::uri] contains ".js") or ([HTTP::uri] contains ".css") or ([HTTP::uri] contains ".png") or ([HTTP::uri] contains ".jpeg") or ([HTTP::uri] contains ".jspg") or ([HTTP::uri] contains ".gif")} {

 

if {$foundmatch} { log local0. "Caching [HTTP::uri]" }

 

CACHE::enable }

 

else {CACHE::disable }

 

}

 

when CACHE_REQUEST { log local0. "[CACHE::hits] cache hits [HTTP::uri]" }

 

 

Thanks for any input

2 Replies

  • when HTTP_REQUEST {

     

    The below irule will log to the ltm logfile so can tail -f it to see the actual files.

     

    Logging can be removed afterwards then.

     

     

     

    set foundmatch 0

     

    if { ([HTTP::uri] contains ".swf") or ([HTTP::uri] contains ".js") or ([HTTP::uri] contains ".css") or ([HTTP::uri] contains ".png") or ([HTTP::uri] contains ".jpeg") or ([HTTP::uri] contains ".jspg") or ([HTTP::uri] contains ".gif")} {

     

    if {$foundmatch == 1} { log local0. "Caching [HTTP::uri]" }

     

    CACHE::enable }

     

    else {CACHE::disable }

     

    }

     

    when CACHE_REQUEST { log local0. "[CACHE::hits] cache hits [HTTP::uri]" }

     

  • Hi Phil,

    A switch statement should be a bit more efficient and simpler to modify:

    
    when HTTP_REQUEST {
       switch -glob [HTTP::path] {
          ".swf" -
          ".js" -
          ".css" -
          ".png" -
          ".jpeg" -
          ".pspg" -
          ".gif" {
             CACHE::enable
             log local0. "Caching [HTTP::uri]"
          }
          default {
             CACHE::disable
          }
       }
    }
    when CACHE_REQUEST {
       log local0. "[CACHE::hits] cache hits [HTTP::uri]"
    }
    

    Aaron