Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

304 Not Modified When If-None-Match is valid

I am optimizing an Express JSON API for consumption by iOS & Android Apps and do not seem to be able to get Express to respond with the correct 304 header when the Apps specify an etag within the If-None-Match header.

I needn't setup Etag generation as Express was already providing those; however when the Apps specify that etag again in a second request; Express' response is still a 200 with the data, as you can see in my tests in Postman:

Postman request with correct If-None-Match header and 200 response

How can I enable this functionality?

Update: The iOS dev is seeing the correct 304 Not Modified responses from the Express server but I don't understand why I am not seeing them within Postman - Does Postman support such actions?

like image 806
Illizian Avatar asked Jun 02 '14 15:06

Illizian


People also ask

What does 304 not modified mean?

The HTTP 304 Not Modified client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource.

What are the If modified since and if none match headers used for?

The If-Modified-Since header is used to specify the time at which the browser last received the requested resource. The If-None-Match header is used to specify the entity tag that the server issued with the requested resource when it was last received.

What is the difference between 200 and 304 status code?

200 (cache) means Firefox is simply using the locally cached version. This is the fastest because no request to the Web server is made. 304 means Firefox is sending a "If-Modified-Since" conditional request to the Web server.


Video Answer


1 Answers

I just stumble across this today, you need to disable Postman default behaviour of sending Cache-Control as none. To do this just go to settings change Send no-cache header to No.

enter image description here

like image 146
Orlando Avatar answered Oct 19 '22 04:10

Orlando