网页gzip压缩

客户端发送请求,服务端先压缩数据再响应。

可以在.htaccess里面做如下配置

#GZIP压缩模块配置
  
    #启用对特定MIME类型内容的压缩
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
 
apache要开启deflate_module、filter_module模块

配置成功的话,响应头会有Contet-Encoding: gzip字段

网页gzip压缩_第1张图片



你可能感兴趣的:(网站优化)