PDA

View Full Version : Handling of HttpStatus Not Modified (304)



obrand
Jun 15th, 2011, 04:08 PM
Hi there,

I have implemented the ETag header on the server side and would like to know how to handle this case on the client.
Right now, I have:


ResponseEntity<MyObject> responseEntity = restTemplate.exchange(url,
HttpMethod.GET, requestEntity, MyObject.class);

As a 304 response does not send back a body, I get a: ResourceAccessException

What is the best way to treat the 304 case?

Thanks in advance

Olivier

Roy Clarkson
Jun 28th, 2011, 11:57 AM
Hi Olivier, a 304 response simply means the content has not changed, so to save bandwidth the server is not returning the same content again. How you handle this depends on the requirements of the client. You may want to cache the data from a previous request, and use that cached data when you receive a 304.

-Roy