Understanding of HTTP 304 (RPM)

Source: Internet
Author: User

Understanding of HTTP 304 (RPM)

Recently with colleagues to see the web cache problem, and further understanding of HTTP 304 and some understanding.

The standard explanation for 304 is that the not Modified client has a buffered document and makes a conditional request (typically providing a if-modified-since header indicating that the customer only wants to update the document over 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.
Therefore, for the dynamic page cache acceleration, first to add the last Modified definition in the HTTP Header of the Response, followed by the If Modified Since and the requested content update time in request to return 200 or 30 4. Although the database query has been done at the time of return 304, but can avoid the next more database query, and do not return the page content and just an HTTP Header, thereby greatly reducing the bandwidth consumption, the user's feeling is also improved.
When these caches are in effect, looking at a request through HttpWatch will result in this:
First time Visit 200
Mouse click two times Access (Cache)
Press F5 to refresh 304
Press Ctrl+f5 to force refresh 200
If so, it means the cache is really working. This is my understanding of HTTP 304.
Original posts: http://bulaoge.com/topic.blg?dmn=webdev&tid=301677

Understanding of HTTP 304 (RPM)

Related Article

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.