Forum Discussion
Brett_Channon_1
Nimbostratus
Aug 04, 2005writing 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_95363Historic F5 AccountThis 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... - Darryl_Wilson_2
Nimbostratus
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_12Historic F5 AccountThere 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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
