X-Accel-Redirect
pepejose
nginx-forum at nginx.us
Wed Sep 30 13:12:29 MSD 2009
Jeff Waugh Wrote:
-------------------------------------------------------
> >
> > -- In the first case X-Accel-Redirect not
> working because the image is in
> > memory? -- If I change the second case to:
> >
> > header("Content-type: image/jpeg");
> header("X-Accel-Redirect: /$image");
> > readfile($image);
> >
> > how can I know if the header X-Accel-Redirect is
> working?
>
> The X-Accel-Redirect header basically says:
>
> Dear nginx (or some other frontend),
>
> I know you're talking to me with fastcgi or http
> (proxy), but now I've
> figured out that I'm just going to be sending
> the client a file. You can
> do this better than me (by talking directly to
> the kernel and disk, and
> not sending the file over the fastcgi or proxy
> connection), so here's the
> name of the file.
>
> Love,
>
> Backend Application
>
>
> So, what you want to do in your backend is this:
>
> header("Content-type: image/jpeg");
> if ( X_ACCEL_DIRECT ) { // this shoudl
> configurable in a productised app
> header("X-Accel-Redirect: /$image");
> exit;
> }
> readfile($image); // send the image if we're not
> using X-Accel-Redirect
>
>
> The initial path should probably be mildly more
> unique though, so you can
> deal with it separately in your nginx
> configuration. But not necessarily.
>
> Short answer: X-Accel-Redirect is helpful only
> when the file is on disk.
>
> :-)
>
> - Jeff
>
many thanks to both for responding
in short, how can I verify that X-Accel-Redirect is working?
I looked at the headers with the plugin for firefox live http headers but I see no differences
thanks!!
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,10152,10170#msg-10170
More information about the nginx
mailing list