Forum Discussion

Wil_Schultz_101's avatar
Wil_Schultz_101
Icon for Nimbostratus rankNimbostratus
Jan 26, 2007

Possible to insert header in CACHE_RESPONSE?

I would like to insert a header on cache response so I will quickly know if a page was served from the origin server of from cache. I'm attempting the following:


when CACHE_RESPONSE { 
 if { [HTTP::uri] contains "/" } {
    HTTP::header insert "Via" "Cache"
  log local.cachedresponse
 }
}

And am receiving the following error:


tmm tmm[1025]: 01220001:3: TCL error: Rule testirule  - Out of bounds (line 2)     invoked from within "HTTP::header insert Via: BigIP"

5 Replies

  • bl0ndie_127134's avatar
    bl0ndie_127134
    Historic F5 Account
    You can but you will have to get version 9.4; sorry.

     

     

    On the other hand, you could add the header in HTTP_RESPONSE before it gets cached. If the header value does not change between requests, this would be a preferable method because you will only do this once.
  • So I've tested with the following:

    
    when HTTP_RESPONSE {
      HTTP::header insert "Server" "Cache"
    }

    This does indeed add the header, however it keeps it there whether the response has been previously cached or not. In an ideal world it would be grand to not have the header there if the request was not a cached response,
  • bl0ndie_127134's avatar
    bl0ndie_127134
    Historic F5 Account
    I agree that's a bit of a pia. Are you making the caching decision in HTTP_REQUEST? A lot of folks use data groups to call CACHE::enable of CACHE::disable command to manually enable/disable the cache. If you are also doing that, you could just set a variable as a hint whether or not to add the header on the response. Other wise you will have to get 9.4.