Improve download performance with mod_xsendfile
One of the powerful features of Fakoli is its ability to serve files from action handlers. This allows the ability to provide custom access control to resources such as documents and images, as well as providing a simple mechanism for serving and generating files on the fly, such as thumbnailed images or rendered PDF documents. One drawback of this mechanism is that the files are served from the PHP script, which has performance implications. Serving byte streams from PHP is not particularly efficient compared with serving files from Apache. It also locks up a PHP processing thread while the files are being downloaded. Fortunately there is a simple solution to all this, by virtue of the mod_xsendfile extension for Apache.
mod_xsendfile works by allowing the PHP (or other script) to return a file path to a static file in a custom HTTP response header. mod_xsendfile intercepts these headers and sends the specified file via Apache's regular file handling code, which is much more efficient at handling the output stream.
Fakoli will automatically detect and use mod_xsendfile when it is present, so all you have to do is configure the extension on your server. Here are the instructions:
Step 1 - install mod_xsendfile
On an Ubuntu server, this is a simple apt-get:
apt-get install libapache2-mod-xsendfile
Step 2 - Determine which version of mod_xsendfile was installed
The Apache configuration directives for mod_xsendfile were changed as of version 0.10, so you will need to know which version of mod_xsendfile you are working with (this will depend on the version of your Ubuntu distribution). Run the command:
dpkg -l | grep libapache2-mod-xsendfile
Step 3 - Configure mod_xsendfile directives
With a text editor, create the file /etc/apache2/mods-available/xsendfile.conf. If you are using a version of mod_xsendfile prior to 0.10, put this in the configuration file:
<Files *.php> XSendFile on XSendFileAllowAbove on </Files>
Otherwise, the configuration options are:
<Files *.php>
XSendFile on
XSendFlePath /srv/www/uploads
</Files>
Where /srv/www/uploads is the root file upload area for Fakoli applications on your server (you may need to change this if it is in a different location on your system).
Step 4 - Recycle Apache
Run the command:
apache2ctl restart
Fakoli will then automatically detect that mod_xsendfile has been enabled, and will use it to send all file resources, including generated thumbnails, PDFs, etc.
CompoundSelectFieldRenderer is here to help YOU! » « Fakoli events may be coming to a calendar near you
