Skip to content

Speeding up downloads

Ondřej Košarko edited this page Feb 20, 2017 · 2 revisions

With #469 we've employed XSendFile to speedup bitstream downloads "through" xmlui.

What is XSendFile?

A mechanism that let's you serve static files by web server (proxy) even though you need to first run authentication on the application server (backend).

The proxy looks for a specific http header in backend's response; then it interprets its value to locate the static file on disk.

More details with examples can be found at https://www.nginx.com/resources/wiki/start/topics/examples/xsendfile/

How to configure it

Different web servers look for different http headers; you need to set the header name in your configs. New variable lr.XSendFileHeader was introduced for this reason. For nginx the value is X-Accel-Redirect for apache it's X-SENDFILE. If you leave the value empty the feature will be disabled, downloads will be handled as they were before.

Other variable you need to set is the lr.XSendFilePathPrefix. The interpretations depends again on the web server used. In case of nginx this is the internal location you'll configure; in case of apache this is the file path you'll allow. In either case the PathPrefix somehow corresponds to assetstore directory.

So far we've only used one assetstore.

Examples

Nginx

In the top server element you need to create a new location

location /xsendfile/ {
    internal;
    alias /opt/lindat-dspace/installation/assetstore/;
}

and in local.properties you'll have

lr.XSendFileHeader = X-Accel-Redirect
lr.XSendFilePathPrefix = /xsendfile/

where /xsendfile/ is the internal location you've created - an alias for your installation's assetstore

Apache

Make sure you have mod-xsendfile installed and enabled (aptitude install libapache2-mod-xsendfile, a2enmod). Inside VirtualHost

XSendFile On
XSendFilePath /opt/lindat-dspace/installation/assetstore/

And the properties:

lr.XSendFileHeader = X-SENDFILE
lr.XSendFilePathPrefix = /opt/lindat-dspace/installation/assetstore/
Clone this wiki locally