HTTP 304 error details

Source: Internet
Author: User

The Not Modified client has a buffered document and sends a conditional request (generally, the If-Modified-Since header is provided to indicate that the customer only wants to update the document than the specified date ). The server tells the customer that the original buffer documentation can still be used.

If the client finds that the cached file contains the Last Modified, the request will contain the If Modified Since, which is the Last Modified of the cached file. Therefore, If the request contains If Modified Since, it indicates that the client has been slowed down. You only need to determine the time and the modification time of the Current requested file to determine whether to return 304 or 200. For static files, such as CSS and images, the server automatically compares Last Modified with If Modified Since to complete caching or updating. However, dynamic pages are dynamically generated pages that often do not contain the Last Modified information, so that browsers and gateways do not cache them, that is, a 200 request is completed every time a request is made.

Therefore, for dynamic page cache acceleration, first add the Last Modified definition to the HTTP Header of Response, then, 200 or 304 is returned Based on the If Modified Since in the Request and the Update Time of the requested content. Although a database query has been performed when 304 is returned, more database queries can be avoided, and no page content is returned, instead of an HTTP Header, this greatly reduces bandwidth consumption and improves user experience.

When these caches are valid, you can view a request through HttpWatch and get the following result:

The first access 200

Click the second access (Cache)

Press F5 to refresh 304

Press Ctrl + F5 to forcibly refresh 200

If so, the cache is actually valid. The above is my understanding of HTTP 304.

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.