location / { #root html; #index index.html index.htm; proxy_cache rankCache; proxy_cache_valid 200 301 302 304 1d; proxy_cache_valid any 7d; proxy_pass http://127.0.0.1:3000; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass_header User-Agent; expires 1d; } location ~* .*\.(html|js|css|png|ico|gif|jpg|jpeg)$ { proxy_cache rankCache; proxy_cache_valid 200 301 302 304 1d; proxy_cache_valid any 7d; proxy_pass http://127.0.0.1:3000; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass_header User-Agent; expires 1d; }
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #缓存配置 proxy_cache_path D:/Users/LIWEI564/nginx_rank_cache levels=1:2 keys_zone=rankCache:10m inactive=1d max_size=30m; sendfile on; keepalive_timeout 65; gzip on; server { listen 80; server_name localhost; #导入express-seed.conf中的配置 include express-seed.conf; #location /track/ { # root html; # index index.html index.htm; #} #location / { # root html; # index index.html index.htm; #} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } }
想用nginx反向代理express并启用缓存,但在实际操作过程中,css文件却始终不能缓存。被缓存的文件始终从nginx缓存中取,不再向express发起请求。这让我产生疑虑:如果express的文件发生更新,那么nginx如何能知道,并更新他的缓存?望高手指点一二。