Forum Discussion
Rodrigo_EV_7869
Jul 05, 2008Nimbostratus
As more customers are beginning to use YSlow (http://developer.yahoo.com/yslow/ - a Firefox add-on integrated with the popular Firebug web development tool that analyzes web pages and tells you why they're slow based on the rules for high performance web sites) to better develop their sites and applications, I think this topic can become a little bit more important.
I haven't tried this out yet, but should it work?
when RULE_INIT {
300s=5min, 3600s=1hour, 86400s=1day, 604800=1week
set expire_content_300 0
set expire_content_3600 0
set expire_content_86400 0
set expire_content_604800 0
}
when HTTP_REQUEST {
set expire_content_300 [matchclass [string tolower [HTTP::path]] ends_with ::class_expire_content_300]
set expire_content_3600 [matchclass [string tolower [HTTP::path]] ends_with ::class_expire_content_3600]
set expire_content_86400 [matchclass [string tolower [HTTP::path]] ends_with ::class_expire_content_86400]
set expire_content_604800 [matchclass [string tolower [HTTP::path]] ends_with ::class_expire_content_604800]
}
when HTTP_RESPONSE {
if { $expire_content_300 == 1 } {
HTTP::header replace "Cache-Control" "max-age=300"
HTTP::header replace "Expires" "[clock format [expr ([clock seconds]+300)] -format "%a, %d %h %Y %T GMT" -gmt true]"
} elseif { $expire_static_3600 == 1 } {
HTTP::header replace "Cache-Control" "max-age=3600"
HTTP::header replace "Expires" "[clock format [expr ([clock seconds]+3600)] -format "%a, %d %h %Y %T GMT" -gmt true]"
} elseif { $expire_static_86400 == 1 } {
HTTP::header replace "Cache-Control" "max-age=86400"
HTTP::header replace "Expires" "[clock format [expr ([clock seconds]+86400)] -format "%a, %d %h %Y %T GMT" -gmt true]"
} elseif { $expire_static_604800 == 1 } {
HTTP::header replace "Cache-Control" "max-age=604800"
HTTP::header replace "Expires" "[clock format [expr ([clock seconds]+604800)] -format "%a, %d %h %Y %T GMT" -gmt true]"
} else {
HTTP::header replace Expires -1
}
}
Thanks,
-Rodrigo