I am using nginx for caching requests from the upstream apache server, however I want few blocks inside to be fetched from apache all the time. I am hoping ssi can do this, but the SSI tags are outputted to the user without being preprocessed.
location ~* ^.+\.html$ {
proxy_pass http://localhost:9999;
proxy_cache_key "$prime$scheme$host$request_uri";
ssi on;
ssi_silent_errors off;
log_subrequest on;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Country $country_code;
proxy_cache my-cache;
proxy_cache_bypass $http_x_refresh_cache;
proxy_cache_valid 200 302 30d;
proxy_cache_valid 404 10m;
proxy_cache_valid any 1m;
}
This is the relevant nginx conf.
Best Answer
This line is caching all the individual parts of the page under the same key (the URI that the user typed), so the different parts of the page are overwriting each other, and then only the last one written gets returned. You want to use
$uri
rather than$request_uri
, so that each part of each page is cached under its own personal name.