[uWSGI] Flat file caching in subdirectories

Tim van der Linden tim at shisaa.jp
Mon Jul 11 08:18:52 CEST 2016


On Sun, 10 Jul 2016 16:43:49 +0200
"Roberto De Ioris" <roberto at unbit.it> wrote:

Hi Roberto (and others),

> Hi, write plugins when performance are the main requirement:
> 
> https://gist.github.com/rdeioris/d1ba5b143ce54a0d58233d835fe24653
> 
> uwsgi --build-plugin router_mkdir.c
> 
> then:
> 
> [uwsgi]
> ; load the plugin
> plugin = path_to_router_mkdir.so
> ; example
> route = ^/foo mkdir:/tmp/foo/${SCRIPT_NAME}

I have the following approach in mind:

- Write a plugin to recursively create the directory structure identical to the PATH of the URI (which you almost completed for me - thanks!).
- Write a plugin that extends the router conditions (router-if) to include a "isfreshfile:" check to check if the modification time of the file is not older than X seconds.

The first plugin is "done" with my rather noobish knowledge of C (aka dangerous knowledge of C) and I will push what I have to the gist soon.

The second plugin is also nearly done, yet with the same level of competence, however I have two questions regarding the registration of router conditions. The theoretically usage of this would be:

route-if = isfreshfile:/<path>/<to>/<file>.html,30 static:/<path>/<to>/<file>.html

1. From the source of uWSGI I could find that these conditions can be registered using: the uwsgi_register_router_condition() function (as seen here https://github.com/unbit/uwsgi/blob/master/core/routing.c). However, I get a compiler warning stating that this function does not exist (uwsgi_register_router() does exist and I included the uwsgi headers). What is the approach to register a router condition to be used in "router-if ="?

2. Is it feasible to include the "30" parameter (age in seconds) in a "route-if" condition? How would I access this in C (assuming this is *args in router_xx() call)?

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

Cheers,
Tim


More information about the uWSGI mailing list