【发布时间】:2018-05-02 09:38:57
【问题描述】:
这是我的 .htaccess 文件,我使用了来自 google 的超级缓存插件和 pagespeed。
# TN - START EXPIRES CACHING #
ExpiresActive On
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresDefault "access 1 month"
# TN - END EXPIRES CACHING #
# TN - BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "private"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "private, must-revalidate"
</filesMatch>
</ifModule>
# TN - END Cache-Control Headers
# TN - BEGIN Turn ETags Off
FileETag None
# TN - END Turn ETags Off
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN supercache
<IfModule mod_mime.c>
<FilesMatch "\.html\.gz$">
ForceType text/html
FileETag None
</FilesMatch>
AddEncoding gzip .gz
AddType text/html .gz
</IfModule>
<IfModule mod_deflate.c>
SetEnvIfNoCase Request_URI \.gz$ no-gzip
</IfModule>
<IfModule mod_headers.c>
Header set Vary "Accept-Encoding, Cookie"
Header set Cache-Control 'max-age=3, must-revalidate'
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html A3
</IfModule>
Options -Indexes
# END supercache
Options All -Indexes
如果我停用 cdn,我会在速度测试中出错:
以下可公开缓存、可压缩的资源应具有“Vary: Accept-Encoding”标头: https://droidawy.com/wp-content,_plugins,_mh-lo ... asonry.js,qver==4.2.1.pagespeed.jc.aJe1qC-NMI.js ttps://droidawy.com/wp-content,_themes,_mharty ... t.min.js,qver==1.11.4.pagespeed.jc.vbNvVnCSV-.js https://droidawy.com/wp-content/plugins/heateor ... ront.css,qver=1.4.12.pagespeed.cf.bcGmYWboif.css https://droidawy.com/wp-content/plugins/host-analyticsjs-local/cache/local-ga.js ttps://droidawy.com/wp-content/plugins/mh-auth ... style.css,qver=1.3.1.pagespeed.cf.sg490QkEIx.css https://droidawy.com/wp-content/plugins/mh-love ... style.css,qver=2.1.1.pagespeed.cf.IEZBYGhsBU.css ttps://droidawy.com/wp-content/plugins/mh-maga ... style.css,qver=2.0.1.pagespeed.cf.k8FUittoKh.css 包括/js/jquery/jquery.js,qver=1.12.4.pagespeed.jm.pPCPAKkkss.js https://droidawy.com/wp-includes/js/wp-emoji-release.min.js?ver=4.9
我尝试了这段代码,但没有解决:
<IfModule mod_headers.c>
<FilesMatch ".(js|css|xml|gz|html)$">
Header append Vary: Accept-Encoding
</FilesMatch>
</IfModule>
【问题讨论】: