Forum Discussion
Brett_Channon_1
Nimbostratus
Aug 29, 2006cache based on content type
Hi all,
I wrote this in a bit of a hurry (can you tell!) and figure there must be a better/more efficient way of writing this..
when HTTP_RESPONSE {
if { [HTTP::header Content-Type] conta...
unRuleY_95363
Aug 30, 2006Historic F5 Account
I would try a switch:
when HTTP_RESPONSE {
switch -glob [HTTP::header Content-Type] {
*image/* {
HTTP::header replace Cache-Control public,max-age=604800,must-revalidate,proxy-revalidate
}
text/css -
application/x-javascript {
HTTP::header replace Cache-Control private,max-age=604800,must-revalidate,proxy-revalidate
}
default {
HTTP::header replace Cache-Control private
}
}
}You could also combine the two similar cases merely using an "or":
...
} elseif { ( [HTTP::header Content-Type] equals "text/css" ) or ( [HTTP::header Content-Type] equals "application/x-javascript" ) } {
HTTP::header replace Cache-Control private,max-age=604800,must-revalidate,proxy-revalidate
} else {
...However, this is slightly less efficient because the HTTP::header command still has to be evaluated multiple times.HTH
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