HTTP status Code

Source: Internet
Author: User

When using HttpWatch for packet capture analysis, we often see 200, 301, and 304 of these status codes. What do you mean by the three?

200 means normal 0k, and this is what everyone on earth knows.

301 Moved Permanently indicates that the customer requested the document elsewhere, the new URL is given in the location header, and the browser should automatically access the new URL.

304 Not Modified: The client has buffered files and issued a conditional request (typically providing a if-modified-since header indicating that the customer only wants to update the document than the specified date). The server tells the customer that the original buffered document can continue to be used.

If a client requests a file and discovers that it has a last Modified file cached, then the request will contain the IF Modified Since, which is the cache file's previous Modified. Therefore, if the request contains if Modified Since, it indicates that there is already a cache on the client. As long as you determine the time and the modified time of the currently requested file, you can decide whether to return 304 or 200. For static files, such as: CSS, images, the server automatically completes the comparison of the last Modified and If Modified Since, completing the cache or update. However, for dynamic pages, which are dynamically generated pages, often do not contain the last Modified information, so that browsers, gateways, etc. will not be cached, that is, every request to complete a 200 request.

General Large site image servers have the ability to implement HTTP 304 caching.

This 304 state is usually triggered when the user refreshes the page (F5 key), when the user refreshes the page, because many images in the original page have been cached, the client's browser has recorded the last update time of the image (final Mod), so when the user refreshes the page, A field is submitted to the server: if-modified-since:wed, Sep 21:35:06 GMT

At this time, the server side of the program first to obtain the value of this field, and then the server on the last modification of the time contrast, if the same, directly return 304 not Modified, and then stop. This will not have to transfer the image to the client, to achieve the purpose of saving bandwidth.

About cache-control:max-age= seconds and Expires

Expires = time, HTTP 1.0 version, cache load time, allow client to not check before this time (send request)
Max-age = seconds, HTTP 1.1 version, how many seconds the resource is cached locally.
If Max-age and expires exist at the same time, they are covered by Cache-control max-age.

One drawback of Expires is that the return expiration time is the server-side time, so there is a problem, if the client time and the server time difference is very large, then the error is very large, so in HTTP version 1.1, the use of cache-control:max-age= second replacement.

Summary of all status codes:

1XX (Temporary response)
A status code that represents a temporary response and requires the requestor to continue the operation.

Code description
100 (continued) The requesting person shall continue to make the request. The server returns this code to indicate that the first part of the request was received and is waiting for the remainder.
101 (switching protocol) The requestor has asked the server to switch protocols, and the server has confirmed and is ready to switch.

2XX (Success)
Represents the status code that successfully processed the request.
Code description
200 (success) The server has successfully processed the request. Typically, this indicates that the server provided the requested Web page.
201 (created) The request was successful and the server created a new resource.
202 (accepted) the server has accepted the request but has not yet processed it.
203 (non-authoritative information) the server has successfully processed the request, but the information returned may be from another source.
204 (no content) the server successfully processed the request, but did not return any content.
205 (reset content) the server successfully processed the request, but did not return any content.
206 (partial) The server successfully processed a partial GET request.

3XX (redirected)
Indicates that further action is required to complete the request. Typically, these status codes are used for redirection.

Code description
300 (multiple options) for requests, the server can perform a variety of operations. The server can select an action based on the requestor (user agent) or provide a list of actions for the requestor to select.
301 (permanently moved) The requested page has been permanently moved to a new location. When the server returns this response (a response to a GET or HEAD request), the requestor is automatically forwarded to the new location.
302 (Temporary move) The server is currently responding to requests from a Web page in a different location, but the requestor should continue to use the original location for future requests.
303 (View other locations) The server returns this code when the requestor should use a separate GET request for the different locations to retrieve the response.
304 (not modified) The requested webpage has not been modified since the last request. When the server returns this response, the Web page content is not returned.
305 (using a proxy) the requestor can only use the proxy to access the requested Web page. If the server returns this response, it also indicates that the requestor should use the proxy.
307 (Temporary redirect) The server is currently responding to requests from a Web page in a different location, but the requestor should continue to use the original location for future requests.

4xx (Request error)
These status codes indicate a possible error in the request and hinder the processing of the server.

Code    description  
400   (Error request) The server does not understand the syntax of the request.   the
401   (unauthorized) request requires authentication. The server may return this response for pages that need to log on.  
403   (Forbidden) The server rejects the request. The
404   (not found) server could not find the requested Web page. The
405   (method Disabled) Disables the method specified in the request.  
406   (not accepted) cannot use the requested content attribute to respond to the requested Web page.  
407   (requires proxy authorization) This status code is similar to 401 (unauthorized), but specifies that the requestor should authorize the use of the proxy.
408   (Request timed out)   timeout occurs when the server waits for a request.  
409   (conflict)   The server conflicts when the request is completed. The server must include information about the conflict in the response.  
410   (deleted)   The server returns this response if the requested resource has been permanently deleted.  
411   (requires a valid length) the server does not accept requests that do not contain a valid Content-Length header field.  
412   (precondition not met) the server does not meet one of the prerequisites set by the requestor in the request.  
413   (Request entity is too large) the server cannot process the request because the request entity is too large to exceed the processing power of the server.  
414   (The requested URI is too long) the URI of the request (usually the URL) is too long and the server cannot process it.   The format of the
415   (Unsupported media type) request is not supported by the requested page.  
416   (the request scope does not meet the requirements) if the page cannot provide the requested scope, the server returns this status code.  
417   (unmet expectations) the server does not meet the requirements of the expected Request header field.

5XX (server error)
These status codes indicate that the server has an internal error while trying to process the request. These errors may be the error of the server itself, not the request.

Code description
500 (server internal error) the server encountered an error and could not complete the request.
501 (not yet implemented) the server does not have the capability to complete the request. For example, this code may be returned when the server does not recognize the request method.
502 (Error Gateway) The server receives an invalid response from the upstream server as a gateway or proxy.
503 (Service Unavailable) the server is not currently available (due to overloading or downtime maintenance). Typically, this is only a temporary state.
504 (Gateway Timeout) The server acts as a gateway or proxy, but does not receive requests from the upstream server in a timely manner.
505 (HTTP version not supported) the HTTP protocol version used in the request is not supported by the server.

HTTP status Code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.