Forum Discussion

Darren_Person_2's avatar
Darren_Person_2
Icon for Nimbostratus rankNimbostratus
Aug 17, 2007

RAMCACHE - caching POST?

We just enabled RAMCache utilizing the profiles, but I think we are going to need to use iRules. We are running into an issue with AJAX (doing POST's), but ramcaching thinking that they are GET requests.

 

 

For example, we have a page which has an web module utilizing built in paging. On the first hit of the page, I see the item get put into cache (Using an HTTP Proxy). On the second request (AJAX), I see the POST request being submitted and then I see the cache hit value go up each time. I was under the impression that RAMCACHE did NOT cache POST requests. Am I missing a setting somewhere?

 

 

Any help you can provide would be greatly appreciated!

 

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    The LTM manual states: The RAM Cache feature is fully compliant with the cache specifications described in RFC 2616, Hypertext Transfer Protocol -- HTTP/1.1. This means that you can configure RAM Cache to cache the following content types:

     

    * 200, 203, 206, 300, 301, and 410 responses.

     

    * Responses to GET methods by default.

     

    * Other HTTP methods for URIs specified in the URI Include list or specified in an iRule.

     

    * Content based on the User-Agent and Accept-Encoding values. The RAM Cache holds different content for Vary headers.

     

     

    And HTTP 1.1 does allow caching of the response to a POST request -- from RFC2616, section 9.5:Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header fields.I'd hazard a guess that your POST response is coming back with response code 200 OK and no response headers that would prevent caching. Looking at the http profile (where RAM cache is configured), it doesn't appear that you can configure by method or response code, so the fix would be to have your servers insert cache control headers into POST responses.

     

     

    HTH

     

    /deb
  • Hi Deb - here is the fix - we created an iRule:

     

     

    when HTTP_REQUEST {

     

    set method [HTTP::method]

     

     

    if { $method == "POST" } {

     

    CACHE::disable

     

    }

     

    else {

     

    CACHE::enable

     

    }

     

    }

     

     

    This has fixed the problem - for the record, POST's should not be CACHED! At least, not in a traditional web environment with multiple external users.