[uWSGI] Flat file caching in subdirectories

Tim van der Linden tim at shisaa.jp
Wed Jul 13 12:05:47 CEST 2016


On Wed, 13 Jul 2016 08:40:34 +0200
"Roberto De Ioris" <roberto at unbit.it> wrote:

Hi Roberto

Big thanks for your continued support on this.
 
> The static router tries to automatically detect the content type from the
> file extension.

Hmm, then there might be something else going on.

The extension of the cache files is ".html", each cached files is saved as "file.html" in their respective directives. Yet the static router does not recognize it. Could this be a bug in the static router or should I use a different extension to make the router use the correct header?

> If no extension is available, you'd better to use the
> "file" router that allows key-values options:
> 
> file:filename=foobar,content_type=test/plain,...

Aha, did not know you could also serve like this. Neat :)

> Otherwise you can add headers manually:
> 
> route = ^/foo addehader:Hello: World

Understood.

> Regarding gzip, i strongly suggest you to generate 2 files, one plain and
> one gzipped, using transformations chaining:
> 
> ; store the original response
> route = ^/foo tofile:foobar
> ; gzip it
> route = ^/foo gzip:
> ; save it again with another name
> route = ^/foo tofile:foobar.gz
> 
> then configure the file serving to use the .gz variant if possibile. This
> is way faster and cheaper than gzipping on the fly:
> 
> http://uwsgi-docs.readthedocs.io/en/latest/StaticFiles.html#gzip-uwsgi-1-9

That is an awesome tip and makes sense. I'm looking into speeding the response up as much as possible. I'm still losing roughly 100 ms somewhere (if uWSGI serves a flat file) so Gzipped beforehand might help to drop this some more.

> -- 
> Roberto De Ioris
> http://unbit.com

Cheers,
Tim


More information about the uWSGI mailing list