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)