I tried to figure this out and looked for SO for similar questions, but I still don't have a 100% understanding of how this should work.
I get this response on request for the image resource:
Response Headers Server Apache-Coyote/1.1 Date Mon, 19 Oct 2009 09:04:04 GMT Expires Mon, 19 Oct 2009 09:06:05 GMT Cache-Control public, max-age=120 Etag image_a70703fb393a60b6da346c112715a0abd54a3236 Content-Disposition inline;filename="binary-216-420" Content-Type image/jpg;charset=UTF-8 Content-Length 4719
The desired behavior is that the client must cache it for 120 seconds and then request it again from the server. No request is sent to the server for 120 seconds.
Then, after 120 seconds, the request is sent and the response 304 is received:
Response Headers Server Apache-Coyote/1.1 Date Mon, 19 Oct 2009 09:06:13 GMT Request Headers Host localhost:8080 User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 Accept image/png,image/*;q=0.8,*/*;q=0.5 Accept-Language en-us,no;q=0.8,sq;q=0.7,en;q=0.5,sv;q=0.3,nn;q=0.2 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 300 Connection keep-alive Referer http://localhost:8080/cms/site/0/en/home Cookie JSESSIONID=768ABBE1A3BFABE3B535900233330650; versionsCssDisplayState=block; iceInfo=iceOn:false,activePortletKey:,icePagePanelX:1722,icePagePanelY:3 If-None-Match image_a70703fb393a60b6da346c112715a0abd54a3236
So far, all is well. But then, at the next request (within 120 seconds), I would think that the resource should be cached for 120 new seconds. What I see in the browser (Firefox), on the other hand, is that from that moment on, it always requests a resource and receives a 304 response.
Do I suppose to attach cache control headers in a 304 response? From what I can read in the specification, does it seem that cache controls should be omitted and that the cache should cache it for 120 new seconds automatically?