How to setup Nginx as REALLY static-cache reverse proxy

Reinis Rozitis r at roze.lv
Wed Jan 6 12:49:33 UTC 2016


> I'm having the same issue with cache being browser dependent. I've tried
> setting up a crawl job using wget --recursive with Firefox and Chrome
> headers, but that doesn't seem to trigger server-side caching either.
>
>
> I'd like cache to be browser agnostic.
>
> Any ideas?

It is hard to identify problems without getting a look at the configuration 
but for the sake of general ideas:

For one particular case of static file caching we use nginx's proxy_store 
feature ( 
http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_store ) - the 
files are literally stored as is (in the same tree structure/naming) on the 
cache server.

The configuration is way simple:

proxy_ignore_client_abort on; // optional

upstream backend {
   server 10.10.10.10;
}

server {
     root /path;
     error_page      404 = @store;

     location @store {
        internal;
        proxy_pass           http://imgstore;
        proxy_store          on;
     }
}


Obviously there are some drawbacks (or advantages in some cases) in caching 
this way - the expire headers (or any other headers for that matter) from 
the backend  (or the client) have no effect on the cache server, the cache 
management (purging items / used space) is fully your responsibility, 404 
(or any other non-200) responses are not cached (which might or might not be 
a problem).

rr



More information about the nginx mailing list