Forum Discussion

Brett_Channon_1's avatar
Brett_Channon_1
Icon for Nimbostratus rankNimbostratus
Aug 04, 2005

writing cache control headers.

Hi all,

 

 

I've been looking at some BIGIP info and wondered if anybody knew how easy it was to define/add client cache control headers (such as:Cache-Control: private,max-age=86400,must-revalidate,proxy-revalidate)to outgoing requests from the servers for certain configurable file types.

 

 

Some other LTM products out there are able to do it 'out of the box' but somebody told me that the F5 units dont have any method of doing so without some complex Irule writing.

 

 

Anybody out there already do it?

 

 

Thanks,

 

 

Brett

 

 

 

3 Replies

  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    This is actually a fairly simple iRule (well, as far as iRules go anyway). Now, whether or not something like this should be more easily configured "out-of-the-box" is really a subjective thing. It really depends on how many use cases are likely to do something like that (we haven't come across any yet that have told us). We feel that ultimately, having a powerfully expandable and configurable methodology is better than having just a few capabilities configurable out-of-the-box. Again, this is highly subjective and dependent on just how many instances are doing that "thing".

    Anyway, this rule should get you started:

    First, create a string datagroup/class called my_file_types that contains the extensions for the file types you want the Cache control header added. This will create a configuration object that looks like this in the bigip.conf:

    
    class my_file_types {
       ".htm"
       ".foo"
       ".bar"
    }

    Then make sure your virtual has an HTTP profile and add the following rule (and assign it to your virtual):

    
    when HTTP_REQUEST {
      if { [matchclass [HTTP::uri] ends_with $::my_file_types] } {
        HTTP::header replace Cache-Control "private,max-age=86400,must-revalidate,proxy-revalidate"
      }
    }

    You can then customize this rule for whatever you might eventually want to use to denote the file type. For example, maybe you want to use the Content-Type header instead, or do multiple checks on the URI like does it contain a particular directory element and ends with a particular file type.

    Ultimately, the only way to provide complete flexibility is through the use of a free-form programming language like iRules.

    I hope this stuff doesn't scare you off...
  • Hi,

     

    I am using a simlar iRule to allow client caching of .gif files(HTTP::header)

     

    However, another feature we would like to use is the Ram Cache on the load balancer.

     

    Is there any we can use the two togther ?

     

     

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    There are certainly commands included in iRules to allow you to manipulate the behavior of the RAM-CACHE. Click here

     

     

    This might allow you to combine the logic in the current iRule with some logic that would selectively cache or not cache items as you see fit.

     

     

    Colin