我尝试为Google Speed Insights获得更高的分数。但我对mod_deflate有一些麻烦。它在服务器上处于活动状态,我将代码插入htaccess文件中。请看下面。但是,谷歌没有检测到它。它在www.whatsmyip.org/http-compression-test上进行了测试,并且工作正常。我也尝试留下if标签。但仍然是同样的问题。我错了什么?
RewriteEngine On
# If you install pulse in a sub-folder, some hosts require
# RewriteBase to be set to that sub-folder name (below)
# RewriteBase /subfolder/
############################################################
# RewriteRules for using Pulse with your own template
############################################################
# Uncomment the rules below if you are using your own template
# If embedding to a page other than blog.php, edit that in the rules below
# RewriteRule ^blog-page-([^-]*)$ blog.php?page=$1
# RewriteRule ^blog-([^-]*)+? blog.php?d=$1 [L]
#############################################################
# RewriteRules for using the Pulse template engine
#############################################################
# If you want to place the blog on a url other than /blog,
# change the word "blog" in p=blog to the new url in both rules below
RewriteRule ^blog-page-([^-]*)$ ?page=$1&p=blog [L]
RewriteRule ^blog-([^-]*)+? ?d=$1&p=blog [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?p=$1 [L]
# RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Deflate Compression by FileType
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-shockwave-flash
</IfModule>
# BEGIN Expires-Headers
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 8 hours"
ExpiresByType text/html "access plus 8 hours"
ExpiresByType application/xhtml+xml "access plus 8 hours"
ExpiresByType image/jpg "access plus 30 days"
ExpiresByType image/jpeg "access plus 30 days"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/gif "access plus 30 days"
ExpiresByType image/x-icon "access plus 30 days"
ExpiresByType application/x-shockwave-flash "access plus 30 days"
ExpiresByType text/css "access plus 30 days"
ExpiresByType text/javascript "access plus 30 days"
ExpiresByType application/x-javascript "access plus 30 days"
</IfModule>
# END Expires-Headers
答案 0 :(得分:0)
mmm我有.htaccess:
这是我现在正在使用的网络:100速移动&amp;桌面,100 UX
https://developers.google.com/speed/pagespeed/insights/?url=hotelpuebloupala.com&tab=mobile
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-shockwave-flash
</IfModule>
# turns cache on for 1 month
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType text/html "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType application/xhtml-xml "access plus 600 seconds"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 month"
</IfModule>
<ifmodule mod_headers.c>
<filesmatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "max-age=2592000, public"
</filesmatch>
<filesmatch "\.(css)$">
Header set Cache-Control "max-age=604800, public"
</filesmatch>
<filesmatch "\.(js)$">
Header set Cache-Control "private, max-age=604800"
</filesmatch>
<filesmatch "\.(x?html?|php)$">
Header set Cache-Control "max-age=600, private, must-revalidate"
</filesmatch>
</ifmodule>