Response buffering controls whether generated page output is held on the server or sent progressively to the client. With buffering enabled, ASP can accumulate output and later flush, clear or redirect before the buffered response is committed.
If buffering is disabled, output can be sent as it is generated. When buffering is enabled, output is held until the page completes or Response.Flush sends it. Current IIS Classic ASP configuration enables buffering by default.
<%@ Language=VBScript %>
<% Option Explicit %>
<% Response.Buffer = TRUE %>
<html><head>
<title>(Type a title for your page here)</title>
</head>
<body >
<%
Dim i,j
Response.Write(now)
For i=1 to 10000000
j= j+1 'to waste some time
Next
Response.Write "<br>" & now
%>
</body>
</html>Note: The loop in this example only creates a visible delay for learning purposes; it is not a production waiting technique.
Here both times or time outputs are stored in buffer and posted at one go once the script execution is over.<% Response.Buffer = False %>
You can see the difference as first one output of time will come and after some time the other out put of time will come ( change the value of looping in for loop if gap is more or too less, this is to adjust delay ). Here each line is posted immediately without waiting for the full page to complete its execution.
Response object error 'ASP 0156 : 80004005'
Header Error
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.
Similarly we can't make buffer False when it is On before and send some output in between. Here is the error message we will get
Response object, ASP 0157 (0x80004005)
Buffering cannot be turned off once it is already turned on.
Response.Buffer = True
Response.Write "Old message"
Response.Clear
Response.Write "New message"Output:
New messageResponse.Clear removes only buffered output that has not already been transmitted.
Response.Clear affects data still in the buffer; Response.Flush sends buffered data; headers and redirects must be set before the response is committed.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.