I've run a few experiments with nginx and caching, verified with tcpdump.
Attached is my suggestion for an nginx conf file dealing with multiple
A few things to note:
1. this is not a full nginx.conf, but rather /etc/nginx/conf.d/dhis2
as you would find when installing nginx from deb (which I am going to
2. I've done the proxy pass configs as one-liners which should make
easy for scriptable editing with sed
3. after lots of fiddling with the static content business I have
just dropped it for now. What I have found and confirmed (at least
with chrome) is that chrome is caching this content anyway so there is
only very marginal utility in getting it served by nginx directly from
the file system. It will only be required occasionally. The nginx
cache doesn't work quite like the apache one in that this stuff is not
automatically being cached by the proxy. If it did then this would
far and away be the simplest way to get served directly off the
filesystem. I guess in order to make this happen we have to set the
Cache-Control headers with interceptors from within the webapp. Which
I think this is the right way to go about it anyway. Using the proxy
to fiddle with cache-control headers feels wrong. Either way,
because of the browser caching behaviour its actually a pretty small
optimisation so I'm happy to lose it for now.
Any comments on the conf file?
PS. contrary to popular opinion I think the apache config is actually
much more straightforward, but for the moment it looks like nginx is
clearly superior on memory usage which I think is our primary concern
in most cases.
dhis2 (1.15 KB)