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-revali...
unRuleY_95363
Aug 05, 2005Historic 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...
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
