Gzip 搞死我了。。。

2014-07-20 12:16:12 +08:00
 BOOM
两个都是Wordpress网站,搭建方式基本是一样的.
主题和部分插件略有不同,然后都装了Wordpress Super Cache.
其中一个网站A开启了 压缩页面以便让来访者更快浏览 且成功将40K的网站压缩到了10K.
另一个网站B也试图开启同样的功能,结果却出现330错误,查了PHP错误日志,没有相关信息,再查了一些别的,说是Gzip错误。。。
tool.chinaz.com/gzips/ 查看了出现330错误的B网站,说其开启了Gzip并且已经将页面压缩到了11K,但是去17ce测了一下B网站,Get的数据依旧是40K+
就是想问问,这大概是什么问题。。毫无头绪,如果要解决,该从哪几个方面下手。
谢谢
6898 次点击
所在节点    NGINX
30 条回复
wy315700
2014-07-20 12:20:04 +08:00
Super Cache 里把gzip选项关掉

然后在apache的设置文件里打开gzip 看看
BOOM
2014-07-20 12:23:10 +08:00
@wy315700 用的是Nginx不是apache。
Super Cache里面的已经关了,因为一旦开启整个网站330错误无法访问。
B网站默认开启Gzip,但是貌似没有效果,网站依旧40K多。A网站用了Super Cache后被压缩到了10K不到。
因为B网站和A网站都是基本相同的方式搭建的,所以应该都是可以实现相同的功能的。
但B网站无论如何网站就是40K左右,无法压缩到10K左右。
但是去 chinaz 测试gzip又说已经开启了gzip而且已经被压缩到了10k,去测试发现依旧是40K而不是10K
BOOM
2014-07-20 12:26:18 +08:00
而且网站还出现这个问题:
Uncaught ReferenceError: jQuery is not defined ?f=wp-content/plugins/table-of-contents-plus/front.js&m=1404617869:1
The value "1;" for key "maximum-scale" was truncated to its numeric prefix. kegao.us/:8
Error parsing a meta element's content: ';' is not a valid key-value pair separator. Please use ',' instead. kegao.us/:8
Uncaught ReferenceError: Begin is not defined (index):15
The 'x-webkit-speech' input field attribute is deprecated. Please use the JavaScript API instead.
wy315700
2014-07-20 12:32:13 +08:00
@BOOM nginx配置文件里照样可以打开gzip的啊
BOOM
2014-07-20 12:54:44 +08:00
@wy315700 nginx里面是开启的。不过貌似没有效果。。。
ovear
2014-07-20 12:59:46 +08:00
330是gzip重复压缩了。。
BOOM
2014-07-20 13:14:34 +08:00
@ovear 那不对啊。a网站开没开super cache 都显示已经开启gzip。。。
b网站我进nginx里面关了gzip再开启wordpress super cache都依旧显示330。。
skydiver
2014-07-20 13:43:01 +08:00
@BOOM 你改配置之后重启nginx和php-fpm了么。。。
BOOM
2014-07-20 13:45:06 +08:00
@skydiver 呀。忘记了。。
AstroProfundis
2014-07-20 13:54:34 +08:00
标准结局23333
BOOM
2014-07-20 13:55:34 +08:00
@skydiver 主要是另一个网站也是默认在nginx里面开了gzip,但是再在super cache 里面开压缩也不会出现330啊。
BOOM
2014-07-20 16:10:25 +08:00
@skydiver 刚刚试了,没有用。就是关了gzip再开super cache也会出现330.。。
但是正常开gzip不开super cache就没问题。。
AstroProfundis
2014-07-20 17:01:50 +08:00
楼主把nginx配置贴上来看看吧
BOOM
2014-07-20 18:34:18 +08:00
@AstroProfundis
user www www;
worker_processes auto;
error_log /home/wwwroot/index/log/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
{
use epoll;
worker_connections 51200;
}

http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 4k;
large_client_header_buffers 4 4k;
client_max_body_size 50m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60 60;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 16k;
fastcgi_buffers 16 16k;
fastcgi_busy_buffers_size 16k;
fastcgi_temp_file_write_size 16k;
fastcgi_intercept_errors on;

tcp_nodelay on;
server_tokens off;
gzip on;
gzip_proxied any;
gzip_min_length 1000;
gzip_comp_level 8;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/rss+xml application/xhtml+xml application/atom_xml;
gzip_disable "MSIE [1-6].(?!.*SV1)";
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';

include vhost/*.conf;
server
{
listen 23333;
server_name aaa;
index index.html index.htm index.php;
root /home/wwwroot/index/web;
fastcgi_buffer_size 4k;
fastcgi_buffers 8 4k;
fastcgi_busy_buffers_size 4k;
gzip off;

location ~ .*\.php$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 12h;
}

access_log /home/wwwroot/index/log/access.log combined;
error_log /home/wwwroot/index/log/error.log crit;
}

server
{
listen 80 default;
return 400;
}
}
AstroProfundis
2014-07-20 19:33:24 +08:00
@BOOM 把 gzip_proxied any; 和 gzip_proxied expired no-cache no-store private auth; 这两行注释掉试试?另外还有 server{} 里面的 gzip off;
BOOM
2014-07-20 20:23:01 +08:00
@AstroProfundis 谢谢 我试一试。
server{}里面那个是控制面板的gzip 应该没有关系的。
BOOM
2014-07-20 20:38:04 +08:00
@AstroProfundis 试了,没用。现在正在搭建新环境,看是不是还这样。。
youling
2014-07-20 20:43:38 +08:00
10k和40k有区别吗?
这区别人能感觉出来?
wwqgtxx
2014-07-20 20:57:00 +08:00
@youling 手机党表示很明显
BOOM
2014-07-21 11:36:03 +08:00
@youling 网络不好的时候你就知道了。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/123556

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX