[英]gzip compression for a wordpress home page
Google pagespeed wants me to enable compression for my example.com/ Google Pagespeed希望我为example.com/启用压缩
my site is powered by wordpress so this is a php generated html page
我的网站由wordpress驱动,所以这是一个php生成的html页面
I have enabled compression like so (apache) 我已经启用压缩(apache)
# Mod Deflate performs data compression
<IfModule mod_deflate.c>
<FilesMatch ".(js|css|html|php|xml|jpg|png|gif|svg)$">
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE no-gzip
</FilesMatch>
</IfModule>
how can I enable for the main page (/)? 如何启用主页(/)?
On apache you need to modify your .htaccess
file and add the following 在apache上,您需要修改
.htaccess
文件并添加以下内容
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
This is a more detailed approach to your already working one. 对于已经使用的方法,这是一种更详细的方法。
Important Note: Google PageSpeed Insights will detect a lack of gzip compression if any third party resources are not served gziped. 重要说明:如果未以gzip提供任何第三方资源,则Google PageSpeed Insights将检测到gzip压缩不足。 You may see more here .
您可能会在这里看到更多。
Ok, solved, by using WP Super Cache and enabling "Compress pages so they're served more quickly to visitors" 好了,可以通过使用WP Super Cache并启用“压缩页面,以便更快地将其提供给访问者”来解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.