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
- dennypayne
Employee
This rule is in the wiki, so it seems HTTP::header is valid within CACHE_REQUEST (although the wiki does not definitively call this out):when CACHE_REQUEST { if { [HTTP::header "Content-Length"] equals "0" } { CACHE::expire log local.tooshort } }
Is your logging working and what does it show?
Denny - bl0ndie_127134Historic F5 AccountUh ... why don't you just set the minimum object size to be a non zero value in the ramcache http profile?
- Wil_Schultz_101
Nimbostratus
Well, there are two reasons...
Firstly, the minimum size value does not seem to work every time. It works most times, but for unexplained reasons I still see zero length, or close to it, pages that have the "Age: " header that is inserted by the BigIP.
Secondly, the end goal is not to just look for zero length pages. We have some important pages that might be partially cached downstream from the BigIP, which the BigIP sees as okay and caches as well. Then we have a difficult time clearing all the different points. If I can look for certain headers I can use an iRule expire these pages and keep it dynamic.
An example operation might be, 'if content-length > 50' on a page that is known to be 100. - bl0ndie_127134Historic F5 AccountThe logic for calculating the min size is pretty darn simple. If the minimum size is not working then its a bug. Do you have responses that don't have a content length header (just 'Connection: close')? Can you open a support case so that I can peek at the packet captures for the cases where it does not work?
Now if you have a more complicated logic, I suggest that you use CACHE::disable in HTTP_RESPONSE event to prevent the response from being added to the cache in the first place. You will also want to add a 'Cache-Control: no-cache' header to prevent it from being cached down stream. - Wil_Schultz_101
Nimbostratus
Sorry, here is an example. I have "Minimum Object Size" set to 500 bytes yet I still receive the following page.Profile my_profile | URI /blank.htm | Host www.my.com | 16 hits Size 208 | Received 2007-02-12 14:44:09 Last sent 2007-02-12 14:44:12 | Expires 1969-12-31 16:00:00 Vary none Vary count 1 [root@bigip1:Active] confighttp://www.my.com/blank.htm GET /blank.htm HTTP/1.1 Host: www.my.com User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Pragma: no-cache Cache-Control: no-cache HTTP/1.x 200 OK Connection: Keep-Alive Date: Mon, 12 Feb 2007 22:45:55 GMT Age: 106 Content-Length: 6 Server: Apache-Coyote/1.1 Etag: W/"6-1169519270000" Last-Modified: Tue, 23 Jan 2007 02:27:50 GMT Content-Type: text/html - bl0ndie_127134Historic F5 AccountDo you by any chance have defined an cache uri include that will match '/blank.htm'? The URI includes take precedence over all the configuration and will force the document to get cached regardless of the mix/max water marks. Otherwise go ahead and open a support case and we will look at it.
- Wil_Schultz_101
Nimbostratus
Posted By bl0ndie on 2/12/2007 2:51 PM
The logic for calculating the min size is pretty darn simple. If the minimum size is not working then its a bug. Do you have responses that don't have a content length header (just 'Connection: close')? Can you open a support case so that I can peek at the packet captures for the cases where it does not work?
Now if you have a more complicated logic, I suggest that you use CACHE::disable in HTTP_RESPONSE event to prevent the response from being added to the cache in the first place. You will also want to add a 'Cache-Control: no-cache' header to prevent it from being cached down stream.
The problem with this is that I want these things to be cached by the bigip _and_ by other mechanisms, but it would also be nice to have logic in place that would notice an abnormality and force a re-evaluation to minimize known problems. - Wil_Schultz_101
Nimbostratus
Posted By bl0ndie on 2/12/2007 2:58 PM
Do you by any chance have defined an cache uri include that will match '/blank.htm'? The URI includes take precedence over all the configuration and will force the document to get cached regardless of the mix/max water marks. Otherwise go ahead and open a support case and we will look at it.
The includes, excludes and pins are all empty. - Wil_Schultz_101
Nimbostratus
Ticket is opened: c329237 - Wil_Schultz_101
Nimbostratus
Posted By wschultz on 2/12/2007 3:07 PM
Ticket is opened: c329237
tcpdump and quickview has been sent as well...
Thanks again...
-Wil
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
