这是我的.htaccess文件,我使用谷歌的超级缓存插件和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>
答案 0 :(得分:0)
SiteGround的SuperCacher插件(通常)不需要对.htaccess文件进行任何修改。
删除.htaccess中的超级缓存条目,然后重新启用CDN,清除CDN缓存,然后重试。
在旁注中,请考虑使用检查器中的Google Chrome审核标签来测试您网站的速度,因为许多在线工具都会假设您的托管不是真的。特别是,许多工具都针对HTTP / 1.1服务器,而SiteGround提供HTTP / 2(在提供内容方面,这是一个完全不同的范例)。
祝你好运。