rb1980_75708
Nov 21, 2008Nimbostratus
not caching on stream_matched problem
I have an interesting problem I'm hoping can be solved with an iRule:
I have a cgi that proxies to a back-end verity cluster to retreive search results. Occasionally, (because of a problem on the verity servers) I get a bogus reply with 0 results. This ends up getting cached on WA and served to subsequent requests for the same search.
Here is an example of one of the bogus search results:
{
"gutter_url" : "",
"sort_order" : "popularity",
"sort_by" : "album",
"num_results" : 0,
"status" : "SUCCESS",
"type" : "BROWSE",
"elapsed" : 10.086959
}
I'd like to have rule that follows this basic logic:
1. Identify search request by uri starts_with "/search-cgi"
2. Look for above string '"num_results" : 0,' in response to above request.
3. Tell WA to not cache this response.
I have the basic shell of the iRule as follows, but it's not working: The WAM is still caching the response and serving the next request with X-Pvinfo code S10102. Another thing I cannot figure out how to do is send a no-cache header on the response so the client browser does not cache it locally.
I'd appreciate any help with this.
when HTTP_REQUEST {
set searchreq 0
if { [HTTP::uri] starts_with "/search-cgi" } {
set searchreq 1
log local0. "SEARCH REQUEST: [HTTP::uri]"
}
}
when HTTP_RESPONSE {
STREAM::disable
if {$searchreq == 1} {
STREAM::expression {@"num_results" : 0,@}
STREAM::enable
}
}
when STREAM_MATCHED {
set badreq 1
log local0. "BAD SEARCH RESULT: [STREAM::match]"
not working for WAM:
CACHE::disable
}