当前位置: > Linux服务器 > nginx >

Nginx的缓存问题

时间:2014-12-27 19:14来源:linux.it.net.cn 作者:IT
我在Nginx配置中已经配置了缓存,并且指定了缓存的路径/nginx/proxy_cache_dir,/nginx/proxy_cache_dir目录的权限也已经能让nobody写入的,但是我的nginx运行两天了,在/nginx/proxy_cache_dir目录下面压根就没看到有什么缓存的文件,更别说什么levels=1:2中的一级缓存二级缓存了,请问这是怎么回事的啊?


操作系统的目录大小,操作权限如下

 

[root@yxwebapp1 ~]# cd /nginx/
[root@yxwebapp1 nginx]# du -sh ./*
4.0K	./client_body_temp
64K	./conf
4.0K	./fastcgi_temp
16K	./html
22M	./logs
16K	./lost+found
12K	./on
4.0K	./proxy_cache_dir
4.0K	./proxy_temp_dir
664K	./sbin
4.0K	./scgi_temp
4.0K	./uwsgi_temp
[root@yxwebapp1 nginx]# pwd
/nginx
[root@yxwebapp1 nginx]# ls -l proxy_cache_dir/
总计 0
[root@yxwebapp1 nginx]# ls -l proxy_temp_dir/
总计 0
[root@yxwebapp1 nginx]# ls -l
总计 68
drwx------ 2 nobody root  4096 05-18 15:49 client_body_temp
drwxr-xr-x 2 root   root  4096 05-20 08:35 conf
drwx------ 2 nobody root  4096 05-18 15:49 fastcgi_temp
drwxr-xr-x 2 root   root  4096 05-19 17:12 html
drwxr-xr-x 2 root   root  4096 05-18 15:58 logs
drwx------ 2 root   root 16384 05-18 14:58 lost+found
-rw-r--r-- 1 root   root  8425 05-18 16:12 on
drwx------ 2 nobody root  4096 05-18 15:49 proxy_cache_dir
drwx------ 2 nobody root  4096 05-20 09:40 proxy_temp_dir
drwxr-xr-x 2 root   root  4096 05-18 15:31 sbin
drwx------ 2 nobody root  4096 05-18 15:49 scgi_temp
drwx------ 2 nobody root  4096 05-18 15:49 uwsgi_temp
[root@yxwebapp1 nginx]# 

nginx配置如下

 

user  nobody;
worker_processes 8;
error_log  logs/error.log info;
pid        logs/nginx.pid;

worker_rlimit_nofile 40960;

events {
  use epoll;
  worker_connections 40960;
  }

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

  server_names_hash_bucket_size 128;
  client_header_buffer_size 	16k;
  large_client_header_buffers 4 64k;

  sendfile 	 		on;
  tcp_nopush     		on;
  tcp_nodelay 	 		on;

  keepalive_timeout 		60;

  gzip 			on;
  gzip_min_length  	1k;
  gzip_buffers     4 	16k;
  gzip_http_version 	1.1;
  gzip_comp_level 	2;

  gzip_types       text/plain application/x-javascript text/css application/xml;
  gzip_vary on;

  client_max_body_size       16m;
  client_body_buffer_size    256k;
  proxy_connect_timeout      90;
  proxy_send_timeout         90;
  proxy_read_timeout         90;
  proxy_buffer_size          16k;
  proxy_buffers         4    64k;
  proxy_busy_buffers_size    128k;
  proxy_temp_file_write_size 128k;

  proxy_temp_path  /nginx/proxy_temp_dir;
  proxy_cache_path /nginx/proxy_cache_dir levels=1:2 keys_zone=cache_one:256m inactive=2d max_size=300m;

  upstream yxsrv {
       server 10.xxx.xx.xx4:7011;
       server 10.xxx.xx.xx4:7012;
       server 10.xxx.xx.xx8:7013;
	ip_hash;
     }

  server {
    listen       7011;
    server_name  10.xxx.xx.xx8;

    log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
              		'$status $body_bytes_sent "$http_referer" '
              		'"$http_user_agent" $http_x_forwarded_for';
    access_log  logs/access.log access;
    error_page 404 = /404.htm;

   location ~ ^/sgpms\b\/.*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ {
     expires        	  7d;
     proxy_cache_key  	  $uri$is_args$args;
     proxy_cache   	  cache_one;

	if ( !-e $request_filename ) {
        	proxy_pass  http://yxsrv;
	}
    }

    location ~ ^/sgpms\b {
       proxy_pass      	         http://yxsrv;
       proxy_set_header          Host $host:7011;
       proxy_set_header          X-Real-IP $remote_addr;
       proxy_set_header          X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_cache_key 		 $uri$is_args$args;
       proxy_cache   	         cache_one;
    }

    location ~ ^/nginxstatus$ {
       stub_status             on;
       access_log              on;
       allow 10.xxx.xx.204;
       deny all;
    }
  }
}
(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容