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 ?

anjanesh
  • 337
  • 1
  • 3
  • 11

1 Answers1

16

There is no point to sending a message body with a 304 response. 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.

squillman
  • 37,883
  • 12
  • 92
  • 146
  • 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. – anjanesh Aug 09 '10 at 02: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. – squillman Aug 09 '10 at 03: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" http://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 ! – anjanesh Aug 09 '10 at 23:16