nginx gzip 浏览器缓存

加咧个油 发布于 2011/09/16 16:37
阅读 1K+
收藏 0

nginx.conf开启了gzip,但是google page speed online和百度统计测试并没有压缩CSS啊之类的,浏览器缓存也没有启用

user  nginx;
worker_processes  10;
worker_rlimit_nofile 100000;

error_log   /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
    use epoll;
}


http {
    include       /etc/nginx/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;

    expires max;

    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;
    server_tokens   off;
    gzip on;
    gzip_static on;
    gzip_min_length 0;
    gzip_buffers 4 16k;
    gzip_http_version 1.1;
    gzip_comp_level 5;
    gzip_vary on;
    keepalive_timeout  65;
    limit_zone   myzone  $binary_remote_addr  10m;
    client_max_body_size 20m;

    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80;
        server_name  w7zt.com www.w7zt.com;

        access_log  /var/log/nginx/w7zt.com.access.log  main;

        location / {
            root   /usr/share/nginx/html/w7zt.com;
            index  index.php index.html index.htm;

	    #### WordPress Rewrite rules
	    if (!-f $request_filename){
		set $rule_0 1$rule_0;
	    }
	    if (!-d $request_filename){
		set $rule_0 2$rule_0;
	    }
	    if ($rule_0 = "21"){
		rewrite /. /index.php last;
	    }
        }    

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html;
        }

        location ~ \.php$ {
            root           html/w7zt.com;
            #fastcgi_pass   127.0.0.1:9000;
	    fastcgi_pass unix:/var/run/php-fcgi.sock;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
	    fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html/w7zt.com$fastcgi_script_name;
            include        fastcgi_params;
        }

    }

}

Web地址,http://w7zt.com,帮忙看下是nginx.conf配置错误,还是配置正确但是没有生效。

加载中
0
__FresHmaN
__FresHmaN

使用gzip在安装nginx 的时候引入http_gzip_static_module.

你可以通过/usr/local/nginx/sbin/nginx -V 查看configure arguments看看是否包含该模块

0
mark35
mark35
白渡蜘蛛好像是HTTP1.0不支持gzip压缩
0
mark35
mark35

引用来自“李春强”的答案

使用gzip在安装nginx 的时候引入http_gzip_static_module.

你可以通过/usr/local/nginx/sbin/nginx -V 查看configure arguments看看是否包含该模块

http_gzip_static_module模块是支持读取相同文件名但后缀为.gz的文件(预压缩),和gzip/deflat动态压缩无关。
返回顶部
顶部