Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7681067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:15:28+00:00 2026-05-31T18:15:28+00:00

I am experimenting with various responses from a simple NodeJS HTTP server. The effect

  • 0

I am experimenting with various responses from a simple NodeJS HTTP server.
The effect I am trying to achieve is faster visual rendering of a web page. Since the response is streamed to the browser with transfer-encoding: chunked (right?) I was thinking I could render the page layout first and the rest of the data after a delay.

var http = require('http');

http.createServer(function (req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html'
        , 'Transfer-Encoding': 'chunked'
    });
    res.write('<html>\n');
    res.write('<body>\n');
    res.write('hello ');
    res.write('</body>\n');
    res.write('</html>\n');
    setTimeout(function () {
        res.end('world');
    },1500);
}).listen(3000, '127.0.0.1');

The thing is that it seems as if the response isn’t sent until res.end('world') unless the already written data is long enough, so for instanceres.write(new Array(2000).join('1')) instead of thatres.write('hello'), would do the trick.

Is Node buffering my writes until the data is sizable enough to be sent? If that is the case, is the chunk size configurable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:15:29+00:00Added an answer on May 31, 2026 at 6:15 pm

    It’s possible that the browser is not rendering the data until the closing tags have been read. Try outputting plain text instead of html tags to test this.

    Do you see any input coming into firebug / chrome inspector?

    Related Question

    http://nodejs.org/api/stream.html#stream_stream_write_string_encoding_fd :

    Writes string with the given encoding to the stream. Returns true if
    the string has been flushed to the kernel buffer. Returns false to
    indicate that the kernel buffer is full, and the data will be sent out
    in the future.

    So output the results of .write() methods. See if it returns a true or false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently experimenting with libpcap and various C applications and trying to do accomplish
I've been experimenting with various bits of Java code trying to come up with
Experimenting with Scala... I'm trying to define something analogous to the @ hack in
I have been experimenting with woopra.com A web analytics tool. Which requires a piece
I'm currently experimenting with build script, and since I have an ASP.net Web Part
I am currently experimenting with various input controls and have stumbled upon SneakyInput, which
I'm new to Android application development and I'm currently experimenting with various UI ideas.
We're experimenting with various ways to throttle user actions in a given time period
I'm experimenting with various WYSIWYG javascript text areas. If I try to put a
I've been experimenting with building an Outlook 2010 addin in C#, using Visual Studio

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.