Transfer-Encoding: chunked

HttpTomcatHttp HeadersWebsphereTransfer Encoding

Http Problem Overview


I was trying to understand more on Transfer-Encoding:chunked. referred some articles: http://zoompf.com/blog/2012/05/too-chunky and https://stackoverflow.com/questions/4809774/transfer-encoding-chunked-header-in-php.

I still didn't get very clear picture. I understand setting this encoding allows server to set content in chunk to the browser and cause partial rendering of content at a time that makes web site responsive.

If I've a web application that serves dynamic content (ex: JSF based web app) hosted on IBM WAS, most of the web pages are designed to server rich static content with lots of CSS and JS files + dynamic content. How can I set transfer-encoding 'chunked' for my pages? Or in other words:

  • How do you decide which page will have 'Transfer-Encoding: chunked' and how do you set it for that page?

Your personal experience will certainly be valuable for my understanding.

Http Solutions


Solution 1 - Http

Transfer-Encoding: chunked isn't needed for progressive rendering. However, it is needed when the total content length is unknown before the first bytes are sent.

Solution 2 - Http

When the server needs to send large amount of data, chunked encoding is used by the server because it did not exactly know how big (length) the data is going to be. In HTTP terms, when server sends response Content-Length header is omitted by the server. Instead server writes the length of current chunk in hexadecimal format followed by \r\n and then chunk, followed by \r\n (Content begins with chunk size in hex followed by chunk)

This feature can be used for progressive rendering; however the server needs to flush the data as much as possible so that client can render content progressively (in case of html,css etc)

This feature is often used when server pushes data to the client in large amounts - usually in large size (mega/giga)

Mozilla Documentation

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVickyView Question on Stackoverflow
Solution 1 - HttpJulian ReschkeView Answer on Stackoverflow
Solution 2 - HttpwebjockeyView Answer on Stackoverflow