Skip to content

Add a note that Apache requires extra config for mod_xsendfile #10794

Closed
@mpdude

Description

@mpdude

https://symfony.com/doc/current/components/http_foundation.html#serving-files suggests that Symfony will automagically leverage the mod_xsendfile module to efficiently send files.

As symfony/symfony#24897 correctly points out, this is not true: BinaryFileResponse will only make use of mod_xsendfile if a particular header is present, which is not the default case for Apache.

So, in fact, users might be sending out their files through PHP, even if they have mod_xsendfile installed. Probably they are not aware of this.

One way of fixing this is to enable the mod_headers Apache module and add the following to the Apache configuration:

<IfModule mod_xsendfile.c>
   # This is already present somewhere...
   XSendFile on
   XSendFilePath ...some path...

   # This needs to be added:
   <IfModule mod_headers.c>
      RequestHeader set X-Sendfile-Type X-Sendfile
   </IfModule>
</IfModule>

My suggestion is to add a warning/info box somewhere near https://symfony.com/doc/current/components/http_foundation.html#serving-files.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions