免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3609 | 回复: 1
打印 上一主题 下一主题

[Web] Nginx的缓存配置似乎没有起作用,是什么原因呢? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-07-12 00:08 |只看该作者 |倒序浏览
本帖最后由 hjp0021 于 2011-07-12 09:09 编辑

我的目的就是配置静态的内容由nginx处理,并缓存到指定目录:/webcache/。
而jsp则交给tomcat处理。

经过测试发现缓存目录中/webcache/并没有内容。
是我的配置有问题吗?如何验证缓存是否起作用?
  1. http {
  2.     include       mime.types;
  3.     default_type  application/octet-stream;

  4.     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  5.     #                  '$status $body_bytes_sent "$http_referer" '
  6.     #                  '"$http_user_agent" "$http_x_forwarded_for"';

  7.     #access_log  logs/access.log  main;

  8.     #tcp_nopush     on;

  9.     #keepalive_timeout  0;
  10.     #keepalive_timeout  65;

  11.     #gzip  on;
  12.     server_names_hash_bucket_size 128;
  13.     client_header_buffer_size 32k;
  14.     large_client_header_buffers 4 32k;
  15.     client_max_body_size 300m;
  16.     sendfile on;
  17.     tcp_nopush on;
  18.     keepalive_timeout 60;
  19.     tcp_nodelay on;
  20.     client_body_buffer_size 512k;
  21.     proxy_connect_timeout 5;
  22.     #proxy_read_timeout 5;
  23.     proxy_read_timeout 60;
  24.     proxy_send_timeout 5;
  25.     proxy_buffer_size 16k;
  26.     proxy_buffers 4 64k;
  27.     proxy_busy_buffers_size 128k;
  28.     proxy_temp_file_write_size 128k;
  29.     proxy_temp_path /webtemp;
  30.     proxy_cache_path /webcache levels=1:2 keys_zone=cache_one:50m inactive=1d max_size=10g;
  31.    
  32.     upstream tomcat_server
  33.     {
  34.         server localhost:8888;
  35.         ip_hash;
  36.     }
  37.     server {
  38.         listen   88;
  39.         server_name localhost;
  40.         index index.html index.htm index.jsp default.jsp index.do default.do;
  41.         root /nginx/html/docs;
  42.         if (-d $request_filename)
  43.         {
  44.                 rewrite ^/(.*)([^/])$ http://%host/$1$2/ permanent;
  45.         }
  46.         location ~\.(jsp|jspx|do)?$
  47.         {
  48.                 proxy_set_header Host $host;
  49.                 proxy_set_header X-Forworded-For $remote_addr;
  50.                 proxy_pass http://tomcat_server;
  51.         }
  52.         location ~.*\.(gif|jpg|jpeg|png|bmp|swf)$
  53.         {
  54.                 expires 30d;
  55.         }
  56.         location ~.*\.(js|css)?$
  57.         {
  58.                 expires 1h;
  59.         }
  60.         access_log off;
  61.     }
  62. }
复制代码

论坛徽章:
0
2 [报告]
发表于 2011-07-13 11:33 |只看该作者
这问题不错.和你一起等高手来解决
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP