Sending a binary stream to a client browser

I was wondering if there is a difference in performance (or any other important factor) between the file sent to the browser from our server using this method:

For i = 1 To fileSize \ chunk
  If Not Response.IsClientConnected Then Exit For
  Response.BinaryWrite stream.Read(chunk)
  Response.Flush
Next

VS

The old open file access method that IIS ships with.

We are working on a file manager handler for security reasons and would like to know what performance is.

+3
source share
3 answers

, . , ( ). , , , , , , .

+2

.

, .

: . IIS , .

+2

In my experience, using a script, data flow is much slower than IIS with a high degree of optimization of static file processing. How much slower depends on too many factors that I saw up to 10 times when other bad choices were made (for example, using 4096 bytes as the size of the buffer).

Some things can be improved on IIS7, but if you can get the file as static content, I would definitely go with that.

0
source

Source: https://habr.com/ru/post/1757542/


All Articles