Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling Chrome buffering when streaming text data

We have a site that streams text data over http. It is set up in the following way:

  • It doesn't do any server side buffering
  • Content-Type is text/plain
  • Transfer-Encoding is chunked
  • Compression is disabled

When using plain curl or FireFox, the text gets streamed to the browser to the browser from the first byte. But when using Chrome, no text is displayed until 1024 bytes have been sent. After that, everything show up instantly.

Question: is there a way to disable this buffering behavior?

More info: here is a simple ASP.NET page that demonstrates the behavior:

<%@ language=c# %>

<%
    Response.BufferOutput = false;
    Response.ContentType = "text/plain";

    for (int i=0; i<50; i++)
    {
        Response.Write("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567\r\n");
        System.Threading.Thread.Sleep(1000);
    }
%>

With a web.config that disables compression:

<configuration>
    <system.webServer>
        <urlCompression doStaticCompression="false" doDynamicCompression="false"/>
    </system.webServer>
</configuration>

I also have a live repro running at http://bufferingtest.azurewebsites.net/. Just hit it from both Chrome and FireFox to observe the different behavior.

like image 760
David Ebbo Avatar asked Jan 28 '16 22:01

David Ebbo


People also ask

How do I stop buffering when streaming?

The best way to stop buffering when streaming is to reduce anything that impedes the stream. Here’s some things you can do to achieve that: 1. Close other applications and programs

Why is my Video buffering?

Why do videos buffer? The best way to stop buffering when streaming is to reduce anything that impedes the stream. Here’s some things you can do to achieve that: 1. Close other applications and programs

Is Chromecast buffering issues ruining your movie experience?

Google Chromecast is a popular device for streaming content to your TV. However, it is not without its challenges. The device can experience buffering issues, which ruins the movie-watching experience. If you’re wondering how to resolve your Chromecast buffering issues, help is at hand.

Why does my Netflix keep buffering on and off?

Why does my streaming service keep buffering? Your streaming service is buffering either because your internet connection can’t keep up with the amount of data coming in or your streaming provider can’t push the data to your device fast enough. Learn more about streaming with satellite internet. Will a Wi-Fi extender stop buffering?


1 Answers

Add X-Content-Type-Options: nosniff to your headers and let me know how it goes for you.

According to Mozilla Docs:

The X-Content-Type-Options response HTTP header is a marker used by the server to indicate that the MIME types advertised in the Content-Type headers should not be changed and be followed. This allows to opt-out of MIME type sniffing, or, in other words, it is a way to say that the webmasters knew what they were doing.

like image 168
AnthonyA Avatar answered Sep 24 '22 02:09

AnthonyA