Forum Discussion
Nov 08, 2013
Cache based on SOAP XML Envelope content
Hi guys!
We got a tricky question from our developers. They have a service which gets a bit too much traffic and would like to cache the responses for around 10 seconds based on the content in t...
Nov 11, 2013
A developer of ours came up with a brilliant idea, which I'm trying to implement now. What if we make an md5 out of the content and cache using that?
I wrote the iRule below but despite the devcentral page saying that the CACHE method can be used in the HTTP_REQUEST_DATA it seems like that's not the case.
Thankful for any input!
when HTTP_REQUEST {
if {[HTTP::method] eq "POST"}{
Trigger collection for up to 1MB of data
if {[HTTP::header "Content-Length"] ne "" && [HTTP::header "Content-Length"] <= 524288}{
set content_length [HTTP::header "Content-Length"]
} else {
set content_length 524288
}
Check if $content_length is not set to 0
if { $content_length > 0} {
HTTP::collect $content_length
}
}
}
when HTTP_REQUEST_DATA {
Collect the data needed
set payload [HTTP::payload]
Make the md5sum
set md5 [md5 payload]
Store the uri for later use (the service might not be able to accept a uri)
set uri [HTTP::uri]
Set the uri to current uri+md5
HTTP::uri "$uri?$md5"
Cache the uri to current uri+md5
CACHE::uri "$uri?$md5"
}
when HTTP_RESPONSE {
For troubleshooting
HTTP::header replace X-Via "F5 BigIP (DMZ)"
}
when CACHE_RESPONSE {
For troubleshooting
CACHE::header insert X-CacheStatus "Hit"
CACHE::header insert X-CacheAge [CACHE::age]
}
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