Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have FreeBSD server with nginx as reverse proxy.

When I test it with ab util, I see some strange things, such as:

  1. Internal pages aren't cached.
  2. Main page is cached, but sometimes the non-cached version is returned.

I don't know where I've made a mistake. Please, help.

Here's part of the 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;
        }

    }

}
share|improve this question
add comment

1 Answer

I think you do not fully understand how the cache. Key parameters of the cache, such as:

  • proxy_cache_key
  • proxy_cache_lock
  • proxy_cache_lock_timeout
  • proxy_cache_methods
  • proxy_cache_bypass
  • proxy_cache_valid

I think that the default values ​​give this effect. Read this part of the documentation.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.