[Web-SIG] serving (potentially large) files through wsgi?
manlio_perillo at libero.it
Mon Dec 17 17:56:33 CET 2007
Chris Withers ha scritto:
> Manlio Perillo wrote:
>> 2) handle the range request in the WSGI application.
>> Its not hard as long as you do not implement multiple ranges support.
>> If your object database supports seeks, this should be the most
>> efficient solution.
> This is probably what's wanted. So, if a wsgi app does its own range
> handling, the wsgi server won't interfere?
Yes, it should not interfere (well, with mod_wsgi for nginx it *will*
interfere if you enable the wsgi_allow_ranges directive).
I think that, for your problem, the best solution is to cache the
content of the database on a file, and let the web server to serve that
file (using wsgi.file_wrapper).
That is, you should create a dedicate WSGI application that will map
request URI to your database objects.
Assuming that in you database you store the file data and some metadata
(such as the last modification time), this application will:
1) If the cached file does not exists, dump the content of the database
data on the file
2) If the cached file exists, check if last modification time match;
if not, update the cache file
With this solution, you get the better performance and flexibility
(IMHO), since the web server can handle the static file at its best.
More information about the Web-SIG