Forum Discussion
Any way to cache HEAD request
Hi, I was wandering if anybody had any ideas on how to cache a HEAD request on an f5? Running multiple web sites, HEAD method requests are the worst, as the f5 refuses to cache and the back end servers have to continually process automated bot HEAD requests for pages that change infrequently. Using acceleration web profile would be great if it did HEAD requests. I have tried it in an irule, but f5 web server will always override content length with zero.
Thanks for any thoughts.
6 Replies
First, why would you want to cache a HEAD request? Typically an HTTP header doesn't provide much data to cache to save any significant amount of time when caching it and responding to clients.
- Paul_Z
Altocumulus
Hi, these requests are often complex product list pages with large server overhead, which would be difficult to cache server side. Thats why.
And this in an HTTP header, correct? Typically HTTP headers, which is what you receive with an HTTP HEAD request tend to be less than 16KB in size so I'm not sure why you would be sending data or significant size in an HTTP headers. Can you please expand a bit more as to why you are sending a significant amount of data in an HTTP header?
- Paul_Z
Altocumulus
I'm not sending any significant header data. A HTTP HEAD method request is sent to see if the page has changed & typically has content length & a few other headers, but for just the headers to be returned - the servers have to go through the normal GET method. So the only saving in the whole process is the network traffic of the body not being returned to the requestor. That is why it would be beneficial for the f5 to cache it just like a GET method.
This might work for your purpose but I haven't tested it before so you might consider doing it in a lab or dev environment.
when HTTP_REQUEST { # Check if the request method is HEAD if { [HTTP::method] eq "HEAD" } { # Check if we have a cached response for this request if { [cache lookup -key [HTTP::uri]] ne "" } { # Serve the cached response HTTP::respond 200 content [cache lookup -key [HTTP::uri]] } else { # Cache the response for future HEAD requests (optional) # Continue processing the request and cache the response if applicable cache add -key [HTTP::uri] -value [HTTP::response] # Proceed with the original request forward } } else { # If the method is not HEAD, forward the request normally forward } }
- Paul_Z
Altocumulus
Hi, I will investigate later, but I don't think there is a cache lookup, http::response not valid in http_request & I imaging f5 will return the body along with the headers (when only the headers were requested).
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