Forum Discussion

Dan_Dumont_1403's avatar
Dan_Dumont_1403
Icon for Nimbostratus rankNimbostratus
Dec 20, 2013

Rewriting cache headers before they are used by BigIp

So I have a server behind BigIp that's pretty lame about letting me set cache headers... in short: I can't. So I'd like to try to set the cache headers using an iRule but have them applied before they go through the normal cache processing that BigIp can do.

If the resource at http://server.com/foo.js?v=1 should be (it isn't, there's actually no cache-control header):

Cache-Control: max-age=31557600, public

Is it possible to create an iRule that would have the cache mechanisms currently available for caching content at the BigIp use that header, as well as apply it to any response it sends out?

1 Reply

  • John_Alam_45640's avatar
    John_Alam_45640
    Historic F5 Account

    You could add these header to the http response as the server serves them and the bigIP forwards them.

    At HTTP_REQUEST you identify the objects, at HTTP_RESPONSE you add the header. THis happens the first time the object is served. After the first time, the cache responds with the object, and HTTP_RESPONSE does not trigger.

    when HTTP_REQUEST {
      if { [HTTP::uri] equals "/xyz" } { set insert_hdrs "yes" }
    }
    
    when HTTP_RESPONSE {
      if { $insert_hdrs equals "yes" } { HTTP::header insert cache-control value "..." }
    }