测试地址:https://gtmetrix.com/reports/shikey.com/Bw7asFob
发现了一个问题:可以看错来用户浏览器缓存没有做。
整体还算满意;
先做下预缓存吧:
我参考的是老外这篇文章
https://varvy.com/pagespeed/leverage-browser-caching.html
设置browser cache来加速网站(Leverage browser caching)
直接在你的网站的根目录下找到.htaccess,用Notpad++来编辑(不要使用windows自带的记事本,以免出错),加上如下代码:
- ## EXPIRES CACHING ##
- ExpiresActive On
- ExpiresByType text/css A31536000
- ExpiresByType application/x-javascript A31536000
- ExpiresByType text/x-component A31536000
- ExpiresByType text/html A3600
- ExpiresByType text/richtext A3600
- ExpiresByType image/svg+xml A3600
- ExpiresByType text/plain A3600
- ExpiresByType text/xsd A3600
- ExpiresByType text/xsl A3600
- ExpiresByType text/xml A3600
- ExpiresByType video/asf A31536000
- ExpiresByType video/avi A31536000
- ExpiresByType image/bmp A31536000
- ExpiresByType application/java A31536000
- ExpiresByType video/divx A31536000
- ExpiresByType application/msword A31536000
- ExpiresByType application/vnd.ms-fontobject A31536000
- ExpiresByType application/x-msdownload A31536000
- ExpiresByType image/gif A31536000
- ExpiresByType application/x-gzip A31536000
- ExpiresByType image/x-icon A31536000
- ExpiresByType image/jpeg A31536000
- ExpiresByType application/vnd.ms-access A31536000
- ExpiresByType audio/midi A31536000
- ExpiresByType video/quicktime A31536000
- ExpiresByType audio/mpeg A31536000
- ExpiresByType video/mp4 A31536000
- ExpiresByType video/mpeg A31536000
- ExpiresByType application/vnd.ms-project A31536000
- ExpiresByType application/x-font-otf A31536000
- ExpiresByType application/vnd.oasis.opendocument.database A31536000
- ExpiresByType application/vnd.oasis.opendocument.chart A31536000
- ExpiresByType application/vnd.oasis.opendocument.formula A31536000
- ExpiresByType application/vnd.oasis.opendocument.graphics A31536000
- ExpiresByType application/vnd.oasis.opendocument.presentation A31536000
- ExpiresByType application/vnd.oasis.opendocument.spreadsheet A31536000
- ExpiresByType application/vnd.oasis.opendocument.text A31536000
- ExpiresByType audio/ogg A31536000
- ExpiresByType application/pdf A31536000
- ExpiresByType image/png A31536000
- ExpiresByType application/vnd.ms-powerpoint A31536000
- ExpiresByType audio/x-realaudio A31536000
- ExpiresByType image/svg+xml A31536000
- ExpiresByType application/x-shockwave-flash A31536000
- ExpiresByType application/x-tar A31536000
- ExpiresByType image/tiff A31536000
- ExpiresByType application/x-font-ttf A31536000
- ExpiresByType audio/wav A31536000
- ExpiresByType audio/wma A31536000
- ExpiresByType application/vnd.ms-write A31536000
- ExpiresByType application/vnd.ms-excel A31536000
- ExpiresByType application/zip A31536000
- ## EXPIRES CACHING ##
- 代码2(建议新手使用,我使用的就是这段代码)
- ## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg “access 1 year”
ExpiresByType image/jpeg “access 1 year”
ExpiresByType image/gif “access 1 year”
ExpiresByType image/png “access 1 year”
ExpiresByType text/css “access 1 month”
ExpiresByType text/html “access 1 month”
ExpiresByType application/pdf “access 1 month”
ExpiresByType text/x-javascript “access 1 month”
ExpiresByType application/x-shockwave-flash “access 1 month”
ExpiresByType image/x-icon “access 1 year”
ExpiresDefault “access 1 month”
</IfModule>
## EXPIRES CACHING ##
重新测试一下得分:
显示得分已经为A,一切正常;
另外页面加载的js、css文件过多,其中腾讯微博加载速度过慢。我使用的是这款插件WP MINIFY STATIC,直接在wordpress插件后台搜索即可安装
原理是将css、js文件合并缩减体积,加快加载速度,其实百度云加速也有这个功能
另外将css和、js等静态文件放到又拍云或者七牛云,使用wpsurpercache的cdn功能可能效果更好,但是不像折腾了
我的vps是2M独享相信速度也慢不到哪里去。
测试压缩了大概35%左右的体积,效果还不错。
测试一下全国加载速度,貌似云南不行,因为加上cdn的话其他区域访问会变慢
而且是个个人博客,所以无所谓了。
去掉cdn之后的对比图:
下载速度对比,我用的中原电信CBS,貌似速度还不错。感觉不准~!!!!
至此基本上折腾的差不多了,至于freedomain-cookies,下次有机会再弄吧。
记录一下,希望对大家有所帮助。