Lighttpd, apache and mongrel have the ability to have a Rails application tell the server to send a file from the filesystem. This can be used to provide high speed serving of files by the server, but still allow the app to have some control over what’s served.
Here’s a good description of the Apache module that can do this.
All of the samples show code that look like this (this one’s in PHP):
My question is – how can my app make use of this cool functionality?
Here’s my problem. For each of the servers, the x-sendfile header is disabled by default, since a bad app can send any file on the file system. However, if this is disabled, then my user will see nothing when I return an x-sendfile header!
Here’s the code I’d like to be able to write:
This allows me to use the speedy code path when its available, but if it’s not available for whatever reason my user still gets the file.
I could try to keep duplicate configuration in sync between my app and the web server, but this is prone to error.
Anyone know if I’m missing something here?