NYCPHP Meetup

NYPHP.org

[nycphp-talk] Writing large files to client efficiently

Michael B Allen ioplex at gmail.com
Thu Jan 10 15:16:26 EST 2008


On 1/10/08, John Campbell <jcampbell1 at gmail.com> wrote:
> On Jan 10, 2008 1:49 PM, Michael B Allen <ioplex at gmail.com> wrote:
> > What is the most efficient way to write large files to the client?
> >
> > fpassthru?
> >
> > Mike
>
> Yes.  Make sure you are not output buffering, and don't forget to call
> session_write_close() before running fpassthru() if you are using
> php's default session handler.
>
> I have done this with fpassthru, and i have also used 302 redirects to
> hashed file names.  The latter isn't as secure but it is more flexible
> and faster.  Just as a heads up, fpassthru is going to be a problem if
> you have mutiple servers.

Hi John,

Excellent answer.

In your experience, how much slower is fpassthru compared to serving
static content? Is it twice as slow?

Also, regarding fpassthru on multiple servers, do you mean that with
static files you can redirect to other servers and distribute the
load?

I'm starting to think I should do the hashed filename redirect thing.

Mike

-- 
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/



More information about the talk mailing list