11

For static html pages, when the response header from the server is 304 Not Modified, isn't it the server's responsibility to send back only the headers and not the message-body (html content) along with it ?

Whats the point in sending 304 Not Modified if it comes along with the html content too ?

1 Answer 1

16

There is no point to sending a message body with a 304 response. From RFC 9110:

The 304 (Not Modified) status code indicates that a conditional GET or HEAD request has been received and would have resulted in a 200 (OK) response if it were not for the fact that the condition evaluated to false. In other words, there is no need for the server to transfer a representation of the target resource because the request indicates that the client, which made the request conditional, already has a valid representation; the server is therefore redirecting the client to make use of that stored representation as if it were the content of a 200 (OK) response.

(Below is the original content of this answer based on the earlier RFC 2616:)
In fact, the HTTP specification says that the server must not do so. If you have one that is, it's misbehaving according to the spec.

From the HTTP Specification:

The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields.

3
  • My HTML file resides on a nginx server and on hitting F5, monitoring net activity using FireBug, the bytes returned is the same with response containing message body as well. Commented Aug 9, 2010 at 2:24
  • What's probably happening in your situation is your browser is getting the correctly formed 304 response from nginx and then pulling the page from its cache and passing it on to FireBug. Do you have a tool that will show you the entire conversation? Fiddler or WebScarab would show you the conversation. Commented Aug 9, 2010 at 3:00
  • Thanks. I just verified this using curl. curl --dump-header header.txt --header "If-Modified-Since: Sun, 08 Aug 2010 17:43:07 GMT" myurl.com/page.html cat header.txt HTTP/1.1 304 Not Modified Server: nginx Date: Mon, 09 Aug 2010 23:14:26 GMT Connection: keep-alive ETag: "16f8016-43c-48d536ec440c0" No message body ! Commented Aug 9, 2010 at 23:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.