我正在使用 memcached 来存储准备供 nginx 显示的 html 内容,但我在浏览器中获得的是压缩输出。
如果我关闭 PHP 中的压缩,它可以工作,但响应时间会增加一倍,这是这里的关键部分,所以理想情况下,我想保持压缩并在 nginx 中解压缩。
有什么建议么?
这是会议;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include /usr/local/nginx/conf/mime.types;
server {
listen 80;
server_name mydomain.com;
access_log /path/to/access/log/access_log;
error_log /path/to/error/log/error_log;
root /default/path/to/files;
location ~* \.(jpg|png|gif|css|js|swf|flv|ico|html|woff|ttf|svg|htm)$ {
try_files $uri $uri/ $uri.html @notcached;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 240;
include fastcgi_params;
}
location / {
default_type text/html;
set $enhanced_memcached_key "$server_name$request_uri";
enhanced_memcached_hash_keys_with_md5 on;
enhanced_memcached_pass memcache.local:11211;
error_page 404 = @notcached;
}
location @notcached {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /u1/live/sites/public_html/index.html;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_read_timeout 240;
include fastcgi_params;
}
}
}
答案1
你试过这个吗?如果它符合你的压缩算法,那么这应该对你有帮助:http://openhack.ru/nginx-patched/wiki/MemcachedGzip