S
S
Salavat Sitdikov2013-03-05 10:54:52
Nginx
Salavat Sitdikov, 2013-03-05 10:54:52

Nginx not caching pages?

nginx is installed as reverse proxy with proxy_cache.

When checking for ab, small oddities are observed.
1. When testing the main / - takes from the cache every other time. The first check is normal, the second - everything goes to proxy_pass.
2. Internal sections - the same thing, only now out of 10 cases - only once from the cache takes.

If there is - who can prompt and help, then he is ready to offer a reward for good advice.

Config:

worker_processes  4;

events {
  worker_connections  4096;
}

http {

  proxy_connect_timeout      90;
  proxy_send_timeout         90;
  proxy_read_timeout         200;

  proxy_buffer_size          4m;
  proxy_buffers              24 1m;
  proxy_busy_buffers_size    8m;
  proxy_temp_file_write_size 4m;
  
  proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=all:512m;
  
  keepalive_timeout  65;
    reset_timedout_connection on;
    aio sendfile;
    directio 1M;
    output_buffers 64 256k;
  
  
  server {
    listen < hidden >;
    server_name < hidden >;

    error_page 412 = @fallback;
    
    proxy_cache_key "$host$request_uri";
    proxy_cache_valid 404 5m;
    proxy_cache_valid 500 501 502 503 504 1m;
    proxy_cache_valid any 10m;
    proxy_cache_use_stale http_502 http_503 http_504;
    proxy_cache_bypass $cookie_logined;
    proxy_no_cache $cookie_logined;

    location / {
        if ($cookie_logined) { return 412; }
        proxy_cache all;
        
        proxy_pass < hidden >;
        proxy_redirect < hidden > /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
    }
    
  }

}


OS FreeBSD 8.3
RAM 8Gb

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2013-03-05
@zona7o

in the config you can see that the cookie.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question