Response.Flush in ASP.NET

Author posted by Jitendra on Posted on under category Categories ASP.NET and tagged as Tags with Leave a comment on Response.Flush in ASP.NET

Usage of Response.Flush method in ASP.NET, its disadvantage and advantage of buffering in IIS.

IIS5 enables buffering by default, therefore all the output from your ASP is actually sent to the browser only when the page completes its processing. In many cases this approach improves the overall processing speed, and indirectly makes for a more scalable site.

However, buffering has two minor defects:

  1. The end user might perceive a loss in speed, because she won’t see any output until the page is complete, and
  2. Buffered output has to be maintained on the server, therefore your ASP application is going to take more memory than it would do if buffering were disabled. On server machines with an inadequate amount of memory, large HTML pages can reduce the overall performance.

Fortunately, you can solve both problems with judicious use of the Response.Flush method, that lets you flush the output buffer periodically when sending a large amount of data back to the client. For example, if you are sending back to the client data from thousands of records, you might flush the buffer every 100 records, so that the end user sees some results earlier and you don’t tax the server’s memory.

Disadvantage of Response.Flush:

You can use the Response.Flush method. This method sends output up to that point to the client. Note that clients that connect over slow networks where buffering is turned off, affect the response time of your server. The response time of your server is affected because your server needs to wait for acknowledgements from the client. The acknowledgements from the client occur after the client receives all the content from the server.

For more info, you can read below articles:

Improving ASP.NET Performance

Response.Flush Method

Related posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.