XSendFile is an enhancement over HTTP front end proxy protocol which allows offloading of file uploads and downloads to the front end web server.
collective.xsendfile package adds XSendFile support for Plone.
- Plone handles HTTP request publishing, permission checks, etc. still normally
- But instead of sending the file content over proxy connection Plone sends HTTP response with special header telling the front end web server to read the file from the disk and send the file for the user
Blob handling in ZODB is very effective already (async sockets, just like Apache or nginx would do ). Right after the headers are written to the response, the file gets handed over to the medusa async loop and the Zope thread is freed. This add-on only removes the need to proxy the file data over socket connection. The overhead of this may depend on the use case, so you might want to run some benchmarks before conclusion.
XSendFile support is available as
collective.xsendfile add-on for Plone.
This work is still unfinished as ZODB lacks one crucial feature.
- Put collective.xsendfile to your buildout
- Install the add-on to your site(s) through Plone add-on control panel
- Enable XSendFile module on your front-end web server and virtual host configuration
- In XSendFile Plone control panel, set HTTP header according to your server (Apache/Nginx)
These instructions are for Github (trunk) version.
cd src git clone git://github.com/collective/collective.xsendfile.git
Then include it in the buildout.cfg:
eggs = collective.xsenfile develop = src/collective.xsendfile
collective.xsendfile uses plone.app.registry. You also might need to set up proper ``extends = `` like for Dexterity version pindowns, so that you don't get version conflicts during running buildout.
Install Apache module (Debian/Ubuntu):
# alternatively -thread-dev, depends on your apache configuration sudo apt-get install apt-get install apache2-prefork-dev wget --no-check-certificate https://tn123.org/mod_xsendfile/mod_xsendfile.c sudo apxs2 -cia mod_xsendfile.c
Enable Apache module:
sudo a2enmod xsendfile
Related virtual host configuration file:
Listen 8082 LoadModule xsendfile_module modules/mod_xsendfile.so <VirtualHost *:8082> ServerName test XSendFile on XSendFilePath / RewriteEngine On RewriteRule (.*) http://127.0.0.1:8080/VirtualHostBase/http/test:8082/VirtualHostRoot/$1 [L,P] </VirtualHost>
Here's a nginx.conf, take a closer look at the server locations, that's where the magic happens.
- Apache XSendFile installation instructions (Debian/Ubuntu)
If you get HTTP response like:
OK The requested URL /site-images/xxx/cairo.jpg was not found on this server.
It means a file permission issue? -XXX
Georg Gogo. BERNHARD email@example.com
Jens W. Klein
Mikko Ohtamaa firstname.lastname@example.org