Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the 304 status code count as a "redirect?"

I am currently trying to understand how exactly 304/Not modified qualifies for the 3xx-range class of HTTP status codes. RFC 1945, sec. 9.3 and RFC 2616, sec. 10.3 both read:

This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request.

While "loading from the client's local cache" clearly is a "further action," I am struggling to see how this is a redirect in the sense of HTTP. Am I reading this too literally?

like image 843
DaSourcerer Avatar asked May 14 '14 06:05

DaSourcerer


People also ask

What is the status code of redirect?

The HyperText Transfer Protocol (HTTP) 302 Found redirect status response code indicates that the resource requested has been temporarily moved to the URL given by the Location header.

What does error code 304 mean?

An HTTP 304 not modified status code means that the website you're requesting hasn't been updated since the last time you accessed it. Typically, your browser will save (or cache) web pages so it doesn't have to repeatedly download the same information.

How do I fix error code 304?

Solution: Force Refresh. You then can see 200 response instead of 304 in the browser F12 developer tools network tab.


2 Answers

See http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p2-semantics-26.html#rfc.section.6.4.p.2:

There are several types of redirects:

  1. Redirects that indicate the resource might be available at a different URI, as provided by the Location field, as in the status codes 301 (Moved Permanently), 302 (Found), and 307 (Temporary Redirect).

  2. Redirection that offers a choice of matching resources, each capable of representing the original request target, as in the 300 (Multiple Choices) status code.

  3. Redirection to a different resource, identified by the Location field, that can represent an indirect response to the request, as in the 303 (See Other) status code.

  4. Redirection to a previously cached result, as in the 304 (Not Modified) status code.

like image 88
Julian Reschke Avatar answered Oct 09 '22 11:10

Julian Reschke


I imagine it is because the server is "redirecting" the client to load the requested resource from its local cache instead of downloading it from the server. If the client did not have a local cached copy then it should not be sending a conditional request in the first place.

like image 32
Remy Lebeau Avatar answered Oct 09 '22 10:10

Remy Lebeau