在.htacess中使用Gzip进行压缩以提高www.snapagency上的页面加载速度
Using Gzip for Compression in .htacess to increase page loading speed on www.snapagency
# BEGIN GZIP COMPRESSION <IfModule mod_gzip.c> mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </IfModule> # END GZIP COMPRESSION # BEGIN DEFLATE COMPRESSION <IfModule mod_filter.c> AddOutputFilterByType DEFLATE "application/atom+xml" \ "application/javascript" \ "application/json" \ "application/ld+json" \ "application/manifest+json" \ "application/rdf+xml" \ "application/rss+xml" \ "application/schema+json" \ "application/vnd.geo+json" \ "application/vnd.ms-fontobject" \ "application/x-font-ttf" \ "application/x-javascript" \ "application/x-web-app-manifest+json" \ "application/xhtml+xml" \ "application/xml" \ "font/eot" \ "font/opentype" \ "image/bmp" \ "image/svg+xml" \ "image/vnd.microsoft.icon" \ "image/x-icon" \ "text/cache-manifest" \ "text/css" \ "text/html" \ "text/javascript" \ "text/plain" \ "text/vcard" \ "text/vnd.rim.location.xloc" \ "text/vtt" \ "text/x-component" \ "text/x-cross-domain-policy" \ "text/xml" </IfModule> # END DEFLATE COMPRESSION我尝试过: 我有什么理由不这样做 - 或者人们发现使用插件更容易或更有用吗? wordpress/plugins/gzip-ninja-speed-compression/ 任何缺点或缺点?
What I have tried: Is there any reason why I wouldn't do this - or do people find it easier or more useful to use a plugin instead? wordpress/plugins/gzip-ninja-speed-compression/ Any cons or drawbacks to either?
推荐答案mod_gzip_item_include handler ^ cgi-script mod_gzip_item_include handler ^cgi-script
mod_gzip_item_include mime ^ text /.* mod_gzip_item_include mime ^ application / x-javascript。* mod_gzip_item_exclude mime ^ image /.* mod_gzip_item_exclude rspheader ^ Content-Encoding:。* gzip。* < / IfModule> #END GZIP COMPRESSION #BEGIN DEFLATE COMPRESSION < IfModule mod_filter.c> AddOutputFilterByType DEFLATEapplication / atom + xml\ application / javascript\ application / json\ application / ld + json\ application / manifest + json\ application / rdf + xml\ application / rss + xml\ application / schema + json \ application / vnd.geo + json\ application / vnd.ms-fontobject\ application / x-font-ttf\ application / x-javascript\ application / x-web-app-manifest + json\ application / xhtml + xml\ application / xml \ font / eot\ font / opentype\ image / bmp\ image / svg + xml\ image / vnd.microsoft.icon\ image / x-icon\ text / cache-manifest\ text / css\\ \\ text / html\ text / javascript\ text / plain\ text / vcard\ text / vnd.rim.location.xloc\ text / vtt\ text / x-compo nent\ text / x-cross-domain-policy\ text / xml< / IfModule> #END DEFLATE COMPRESSION mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_exclude mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* </IfModule> # END GZIP COMPRESSION # BEGIN DEFLATE COMPRESSION <IfModule mod_filter.c> AddOutputFilterByType DEFLATE "application/atom+xml" \ "application/javascript" \ "application/json" \ "application/ld+json" \ "application/manifest+json" \ "application/rdf+xml" \ "application/rss+xml" \ "application/schema+json" \ "application/vnd.geo+json" \ "application/vnd.ms-fontobject" \ "application/x-font-ttf" \ "application/x-javascript" \ "application/x-web-app-manifest+json" \ "application/xhtml+xml" \ "application/xml" \ "font/eot" \ "font/opentype" \ "image/bmp" \ "image/svg+xml" \ "image/vnd.microsoft.icon" \ "image/x-icon" \ "text/cache-manifest" \ "text/css" \ "text/html" \ "text/javascript" \ "text/plain" \ "text/vcard" \ "text/vnd.rim.location.xloc" \ "text/vtt" \ "text/x-component" \ "text/x-cross-domain-policy" \ "text/xml" </IfModule> # END DEFLATE COMPRESSION
我尝试过: 我有什么理由不这样做 - 或者人们发现使用插件更容易或更有用吗? wordpress/plugins/gzip-ninja-speed-compression/ 任何缺点或缺点?
What I have tried: Is there any reason why I wouldn't do this - or do people find it easier or more useful to use a plugin instead? wordpress/plugins/gzip-ninja-speed-compression/ Any cons or drawbacks to either?
如果您使用的是Wordpress平台,那么您可以使用插件。因为大多数使用其他功能,如缓存,cdn服务以及gzip。如果您的网站是定制的,那么您可以使用上面的代码。 我建议您使用NGINX或Litespeed来提供更好的内容。 If you are using Wordpress platform, then you can go for plugins. Because most of it use other features like cache, cdn services along with gzip. If your site is custom made, then you can go for the above code. I recommend you to use NGINX or Litespeed for better content delivery.
更多推荐
在.htaccess中使用gzip进行压缩
发布评论