We have a site that streams text data over http. It is set up in the following way:
Content-Type
is text/plain
Transfer-Encoding
is chunked
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.
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 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
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 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?
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 theContent-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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With