Front-end development partners are not often asked for 3XX response status code

Generally, the 3xx that we front end guys know is in the redirection range,

But interviewers will often ask about the role and difference of the common 301, 302, 303, 304, and 307 status codes.

So what does 301 mean

301 is Moved permanently (permanent redirection)

Permanent redirection. The server says to the client: ‘I don’t have the resource you requested, I can’t give it to you, but I can tell you, you can go to this address to get this resource, and in the future this resource will be in the address I gave you, you save this address, don’t ask me for this resource again’.

The actual way the server and client communicate is that the requested resource has been allocated to a new URI(Uniform Resource Identifier) and should be used in the future to which the resource now refers.

What does 302 stand for?

302 in English is Found, temporary redirect, see below

The server tells you: ‘The resource you are requesting is not currently in my possession. It has been temporarily placed on a server at a certain address, but it may be taken from a server at a later date. This time I will give you a temporary address and you can request it.

What does 303 stand for?

303 SeeOther is also a kind of temporary redirect, whether many friends are confused. What the hell? Look at the picture

Server to tell you: “you are now the requested resource is not me this, is put into a temporary address of the server, but possibly from a server that bring them here, after this time, I give you a temporary address you go to the request, but you must use the GET method to which the request, it is difference with 302 status code.

For example, when you use the POST method to access a CGI program, you expect the client to return a 303 status code when it redirects to another URI with the GET method. Although a 302Found status code could do the same thing, 303 is the most reasonable.

When the response status codes 301, 302, and 303 are returned, almost all browsers change POST to GET and delete the body in the request packet. After that, the request is automatically sent again

What does 307 stand for?

307 Temporary Rediract Temporary redirection

Temporary redirection. The status code has the same meaning as 302Found. Although standard 302 prohibits POST from becoming GET, it is not followed in practice.

The 307 will follow browser standards and will not change from POST to GET. However, each browser may have a different situation when it comes to handling the response

The English literal translation of 304 Not Modidied has Not changed

304 belong to 3 xx categories but have nothing to do with the redirection, 304 is a very fun, when the browser to get the status code is 304, will get request from local resources or proxy server directly return to local resources, 304 belong to the cache, this will in future articles written interaction mechanism, Please pay more attention