nginx实现静态压缩这种做法其实就像apache gzip压缩了,这种压缩是我们常见的一些事情了,下面我来介绍一些做法。
在搭建squid网页加速的时候,对于大的css 或者js要进行压缩,然后再进行缓存,这样能够提高减小下载量提高页面响应速度。如果你用的是squid 3.0以前的版本并且用的是 ngnix server的话可能会碰到如下问题: 不用squid直接打开页面则客户端返回的是压缩的状态,如果启用squid加速会发现下载下来的页面不是压缩状态。这里面主要是没有启动ngnix 的静态缓存模块(ngx_http_gzip_static_module)导致。文章源自运维生存时间-https://www.ttlsa.com/nginx/nginx-ngx_http_gzip_static_module/
打开静态缓存问题就解决了文章源自运维生存时间-https://www.ttlsa.com/nginx/nginx-ngx_http_gzip_static_module/
nginx编译选项
./configure --with-http_gzip_static_module
配置nginx
gzip_static on; gzip_http_version 1.1; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6] ."; gzip_vary on; #找不到预压缩文件,进行动态压缩 gzip on; gzip_min_length 1000; gzip_buffers 4 16k; gzip_comp_level 5; gzip_types text/plain application/x-javascript text/css application/xml; #gzip公共配置 gzip_http_version 1.1 gzip_proxied expired no-cache no-store private auth;
gzip_vary on说明
对于支持gzip的请求反向代理缓存服务器将返回gzip内容,不支持gzip的客户端返回原始内容。文章源自运维生存时间-https://www.ttlsa.com/nginx/nginx-ngx_http_gzip_static_module/
其他说明
- gzip_static配置优先级高于gzip
- 开启nginx_static后,对于任何文件都会先查找是否有对应的gz文件
- gzip_types设置对gzip_static无效
文章源自运维生存时间-https://www.ttlsa.com/nginx/nginx-ngx_http_gzip_static_module/
转自:http://www.php100.com/html/program/nginx/2013/0905/5548.html文章源自运维生存时间-https://www.ttlsa.com/nginx/nginx-ngx_http_gzip_static_module/ 文章源自运维生存时间-https://www.ttlsa.com/nginx/nginx-ngx_http_gzip_static_module/

2F
WAWEDADA但是当时的
1F
WAWEDADA但是当时的