Forum Discussion
expiresByType caching
hi,
can i configure caching like in apache? I have to implement below few lines for one VS.
ExpiresByType text/javascript "access plus 12 hours"
ExpiresByType image/gif "access plus 12 hours"
ExpiresByType image/jpg "access plus 12 hours"
ExpiresByType image/jpeg "access plus 12 hours"
ExpiresByType image/png "access plus 12 hours"
ExpiresByType application/x-shockwave-flash "access plus 12 hours"
can you help me with this?
3 Replies
- JRahm
Admin
Here's an old detailed example of what it appears you are trying to accomplish. I've swapped out the findclass command (deprecated in v10+) with the class command:
when HTTP_REQUEST { if {[HTTP::method] eq "GET" and [HTTP::uri] eq "/"}{ set expire_content_timeout 300 } else { set extention [string tolower [string range [HTTP::path] [string last . [HTTP::path]] end]] set expire_content_timeout [class match -value $extention equals cache_timers_by_filetype] } } when HTTP_RESPONSE { if { $expire_content_timeout ne "" } { HTTP::header replace "Cache-Control" "max-age=$expire_content_timeout, public" HTTP::header replace "Expires" "[clock format [expr ([clock seconds]+$expire_content_timeout)] -format "%a, %d %h %Y %T GMT" -gmt true]" } else { HTTP::header replace Expires {-1} } }The data-group format from that old example has changed as well:
ltm data-group internal cache_timers_by_filetype { records { .bmp { data 86400 } .css { data 3600 } .gif { data 86400 } .htm { data 300 } .html { data 300 } .ico { data 604800 } .jpeg { data 86400 } .jpg { data 86400 } .js { data 3600 } .pdf { data 604800 } .png { data 86400 } .swf { data 604800 } } type string } - b_seweryn_15157
Nimbostratus
i see below warning/errors. nothing else:
Warning generated : /Common/cache_2:13: warning: [use curly braces to avoid double substitution][([clock seconds]+$expire_content_timeout)]
and i don't know why from time to time this one (but it is rare error): err tmm[9390]: 01220001:3: TCL error: /Common/cache_2 - can't read "expire_content_timeout": no such variable while executing "if { $expire_content_timeout ne "" } { HTTP::header replace "C ache-Control" "max-age=$expire_content_timeout, public" HTTP::header replace "..."
- b_seweryn_15157
Nimbostratus
ok, i fixed above errors. now logs is clear. It should looks like that:
HTTP::header replace "Expires" "[clock format [expr {[clock seconds]+$expire_content_timeout}] -format "%a, %d %h %Y %T GMT" -gmt true]"now all data types have such age:
Cache-Control:max-age=300, public
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
