How to cache an HTTP POST response?
Posted
by
KARASZI István
on Stack Overflow
See other posts from Stack Overflow
or by KARASZI István
Published on 2010-10-06T15:40:53Z
Indexed on
2010/12/26
13:54 UTC
Read the original article
Hit count: 326
I would like to create a cacheable HTTP response for a POST request.
My actual implementation responses the following for the POST request:
HTTP/1.1 201 Created
Expires: Sat, 03 Oct 2020 15:33:00 GMT
Cache-Control: private,max-age=315360000,no-transform
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Content-Length: 9
ETag: 2120507660800737950
Last-Modified: Wed, 06 Oct 2010 15:33:00 GMT
.........
But it looks like that the browsers (Safari, Firefox tested) are not cacheing the response.
In the HTTP RFC the corresponding part says:
Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header fields. However, the 303 (See Other) response can be used to direct the user agent to retrieve a cacheable resource.
So I think it should be cached. I know I could set a session variable and set a cookie and do a 303 redirect, but I want to cache the response of the POST request.
Is there any way to do this?
P.S.: I've started with a simple 200 OK
, so it does not work.
Thanks,
© Stack Overflow or respective owner