Forum Discussion
Wil_Schultz_101
Nimbostratus
Feb 12, 2007How can I grab an HTTP header on CACHE_REQUEST?
I'm trying to grab [HTTP::header "Content-Length"] to use during CACHE_REQUEST so I can make sure the BigIP does not cache blank pages. I've tried to set a global variable during HTTP::Response and no go. The closest I can seem to find would be to use [CACHE::headers] during CACHE_REQUEST.
What I'm using now, fugly...
when CACHE_REQUEST {
set cheaders [CACHE::headers]
if { $cheaders contains "Content-Length\: 0" } {
log local0.$cheaders
CACHE::expire
}
}
What I would like to get closer to... Looks okay, but doesn't seem to work.
when CACHE_REQUEST {
set cheaders [HTTP::header "Content-Length"]
if { $cheaders == 0 } {
log local1.$cheaders
CACHE::expire
}
}
Version 9.2.4
15 Replies
- spark_86682Historic F5 AccountWhile you could work around this with an iRule, I think that just making a configuration change around that bug would work too. In my tests, adding:
ramcache uri exclude /NOURIWILLEVERMATCHTHIS
- Wil_Schultz_101
Nimbostratus
Posted By spark on 2/13/2007 4:44 PMramcache uri exclude /NOURIWILLEVERMATCHTHIS
- spark_86682Historic F5 AccountYes, that logs the size for me. For example:
Feb 14 08:16:45 tmm tmm[6896]: 01220002:6: Rule dontcache : local0.3624
- spark_86682Historic F5 AccountWow. That's totally weird. From the timestamps it's clear that the response that was logged (and hence excluded from the cache) was not the same one as the one that was cached. Since the hostname is the same, do you have any other rule that might be doing a CACHE::enable on the same virtual? Presumably you'd have checked for that, though. The only other thing I can think of is if somehow there was no content-length header (e.g. via "Connection: close" or chunked content) for a response then the iRule check wouldn't fire.
rule debugcache { when HTTP_RESPONSE { set size [HTTP::header "Content-Length"] if { [HTTP::uri] contains "/blank.htm" } { log "Got blank.html of apparent length $size" } } }
- Wil_Schultz_101
Nimbostratus
edit: I should note that I changed the min size to 1000 and rebooted last night...when HTTP_REQUEST { set ::uri [string tolower [HTTP::uri]] } when HTTP_RESPONSE { set ::size [HTTP::header "Content-Length"] log local0.$::size if { $::uri contains "/blank.htm" } { log "Got blank.html of apparent length $::size" } }
Feb 15 11:54:27 tmm tmm[1013]: 01220002:6: Rule demo.my.com : local0.0 Feb 15 11:54:27 tmm tmm[1013]: 01220002:6: Rule demo.my.com : Got blank.html of apparent length 0 Feb 15 11:54:27 tmm tmm[1013]: 01220002:6: Rule demo.my.com : local0. Feb 15 11:54:27 tmm tmm[1013]: 01220002:6: Rule demo.my.com : Got blank.html of apparent length Feb 15 11:54:28 tmm tmm[1013]: 01220002: repeated 2 times Feb 15 11:54:29 tmm tmm[1013]: 01220002:6: Rule demo.my.com : local0.0 Feb 15 11:54:29 tmm tmm[1013]: 01220002:6: Rule demo.my.com : Got blank.html of apparent length 0 Feb 15 11:54:29 tmm tmm[1013]: 01220002:6: Rule demo.my.com : local0. Feb 15 11:54:31 tmm tmm[1013]: 01220002: repeated 15 times
Profile www.my.com_profile | URI /blank.htm | Host demo.my.com | 159 hits Size 202 | Received 2007-02-15 11:54:29 Last sent 2007-02-15 11:57:25 | Expires 1969-12-31 16:00:00 Vary none Vary count 1
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