Chunked Transfers

In order to enhance the user experience, chunked transfer encoding can be used to allow the Web browser to begin rendering content prior to the entire content being generated and sent. A Web server indicates a chunked response with the following header:

Transfer-Encoding: chunked 

A chunked transfer encoding allows a format in which the content implicitly declares the length of pieces of the response within the content. Consider the following example PHP script:

 <p>This is an example of a time-delayed list:</p> <ul> <? flush(); sleep(3); echo “<li>List item one</li>”; flush(); sleep(1); echo “<li>List item two</li>”; flush(); sleep(1); echo “<li>List item three</li>”; flush(); sleep(1); echo “<li>List item four</li>”; flush(); ...

Get HTTP Developer’s Handbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.