Jeff_C_42204
Aug 01, 2007Nimbostratus
Irule to set expires headers for static conent
Hello Dev Central!
I have an IIS 6.0 server that is not setting the expires header (cache-control is set) which is causing a potential performance issue.
I would like to remedy this by adding the expires header for extensions listed in the images data group.
The following snippet successfuly returns a header "JeffTest" that is 24 hours in the futurein GMT format; so that portion should work just fine for the expires field.
set cachetime 86400
HTTP::header insert JeffTest "[clock format [expr ([clock seconds]+$cachetime)] -format "%a, %d %h %Y %T GMT" -gmt true]"
The problem I am having is that I need it to only be inserted for static content as defined in my images group. I tried the followign which I hoped would work but did not. Is the http:uri function nto allowed in http response? Or is it possible my brackets/bracing are just wrong?
when HTTP_RESPONSE {
if { [matchclass [HTTP::uri] ends_with $::images]} {
set cachetime 86400
HTTP::header insert JeffTest "[clock format [expr ([clock seconds]+$cachetime)] -format "%a, %d %h %Y %T GMT" -gmt true]"
}
If the http::uri function is not allowed in http_response does that mean I have to set two parts to the irule: the first during http::request which matches class and then sets a flag and a second correponding http_response which checks for that flag and if present inserts the header?
Thanks ahead of time for the help!