I try to serve an index page with nginx, using it's proxy_cache functionality. Everything works fine regards ordinary browsing with broswers. But when I try to get page's content with curl or when I use siege on the index page, nginx begins to work not as I have expected. It passes the request further to apache when page's cache is out of date.
I can't understand, why nginx doesn't create a new cache of the index page when it was requested with curl or siege?
Here is a part of nginx.conf:
proxy_cache_path /var/cache/nginx levels=2 keys_zone=pagecache:100m inactive=1m max_size=500m;
location = / {
set $o_uri $request_uri;
if ( $http_cookie !~ "mytestcookie" ) {
rewrite ^ /ng_cache last;
}
proxy_pass http://127.0.0.1:88;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /ng_cache {
internal;
root /home/$host/www;
proxy_cache pagecache;
proxy_cache_valid 200 301 302 304 1m;
proxy_hide_header "Set-Cookie";
proxy_ignore_headers "Cache-Control" "Expires";
proxy_pass http://127.0.0.1:88$o_uri;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}