Auto refresh for expired content?

mkuehn nginx-forum at forum.nginx.org
Thu May 18 14:02:35 UTC 2017


Hi Roman,
hi Francis,

here comes my production config - i made a few tests the last hours, it
always come to the same point - if proxy_cache_background_update is on,
nginx devilvers only the cached content and is not able to fetch a fresh
copy (dont know why) - i tried local files, i tried my production node.js
backend, i even tried an external server as proxy_path - always the same
result... :/
I hope you find something wrong in my configs and then everything is fine ;)
:)
I use centos with nginx/1.12.0

Best regards,
Maik



user nginx;
worker_processes  auto;

pid        /run/nginx.pid;

worker_rlimit_nofile         50000;

events {
    worker_connections  50000;
    use epoll;
    multi_accept on;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request"
'
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;
log_format upstreamlog '[$time_local] $remote_addr - $remote_user -
$server_name  to: $upstream_addr: $request_uri args: $args
upstream_response_time $upstream_response_time msec $msec request_time
$request_time';
    sendfile       on;
    tcp_nopush     on;

    keepalive_timeout   65;
    tcp_nodelay         on;
    types_hash_max_size 2048;

    proxy_cache_path /var/cache/nginx/spieldaten levels=1:2
keys_zone=spieldaten:100m max_size=150m inactive=5d use_temp_path=off;
    

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  xy.com;
        root         /home/nodejs/pcnode;

        access_log             off;
        error_log              off;

        gzip on;
        gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 6;
        gzip_buffers 8 4k;
        gzip_http_version 1.1;
      gzip_http_version 1.1;
        gzip_min_length 256;
        gzip_types text/plain text/css application/json
application/x-javascript text/xml application/xml application/xml+rss
text/javascript;

        try_files $uri @node;

        location @node {
            #access_log  /var/log/nginx/access.log  main;
            access_log off;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://localhost:8088;
            proxy_redirect off;

            proxy_connect_timeout   30s;
            proxy_send_timeout      30s;
            proxy_read_timeout      30s;

            proxy_cache spieldaten;
            proxy_cache_valid 200 302 5m;
            proxy_cache_valid 404 1m;
            proxy_cache_valid any 2m;
            proxy_ignore_headers X-Accel-Expires Expires Cache-Control;
            proxy_cache_use_stale error timeout updating http_500 http_502
http_503 http_504;
            proxy_cache_lock on;
            proxy_cache_background_update on;

        }
     }
 }

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,274264,274298#msg-274298



More information about the nginx mailing list