我是wordpress新手,我在wordpress中建立了一个网站,但是加载时间太长,你能告诉我应该怎么做才能提高性能吗,
我已经安装了缓存插件。
安装一些图像压缩插件Compress JPEG & PNG images
来优化图像,并尝试在页面中使用缩略图图像。
我认为你在页面中使用了全尺寸的图像,尝试使用小尺寸的图像。
//Default WordPress
the_post_thumbnail( 'thumbnail' ); // Thumbnail (150 x 150 hard cropped)
the_post_thumbnail( 'medium' ); // Medium resolution (300 x 300 max height 300px)
the_post_thumbnail( 'medium_large' ); // Medium Large (added in WP 4.4) resolution (768 x 0 infinite height)
the_post_thumbnail( 'large' ); // Large resolution (1024 x 1024 max height 1024px)
the_post_thumbnail( 'full' ); // Full resolution (original size uploaded)
你可以把它放在.htaccess
文件中缓存js, Css和图像文件
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 application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 week"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
- 选择一个好的主机 从一个坚实的框架/主题开始。
- 使用有效的缓存插件
- 使用CDN (content delivery network)
- 优化图像(自动)
- 优化你的主页以快速加载
- 优化你的WordPress数据库。
- 禁用你的内容的热链接和吸取。
- 为静态资源添加过期头
- 调整头像
- 添加LazyLoad到你的图片
- 控制后版本存储的数量
- 关闭pingback和trackback
- 必要时用静态HTML替换PHP
- 使用CloudFlare
在谷歌速度测试工具中测试您的网站,然后按照谷歌为您的网站给出的说明。
谷歌速度测试工具一般工具建议css和js的缩小。您还将被指示优化图像。
这些优化的内容都是谷歌自己给出的,测试完成后。