![](https://i-blog.csdnimg.cn/blog_migrate/b1f40dd90a6371f0edb40a0567642265.png)
wordpress 加速
Do you want to speed up your WordPress site? Fast loading pages improve user experience, increase your pageviews, and help with your WordPress SEO. In this article, we will share the most useful WordPress speed optimization tips to boost WordPress performance and speed up your website.
您想加快WordPress网站的速度吗? 快速加载页面可改善用户体验,增加页面浏览量,并为您的WordPress SEO提供帮助。 在本文中,我们将分享最有用的WordPress速度优化技巧,以提高WordPress性能并加速您的网站。
![How to improve WordPress speed and performance How to improve WordPress speed and performance](https://i-blog.csdnimg.cn/blog_migrate/bf9b23999e1121871e7f4ac2b2d3dac5.png)
Unlike other “X best WordPress caching plugin” lists or generic “X tips to speeding up WordPress” tutorials, this article is a comprehensive guide to WordPress performance optimization.
与其他“ X最佳WordPress缓存插件”列表或通用的“ X加快WordPress技巧”教程不同,本文是WordPress性能优化的综合指南。
We tried to cover everything from why speed is important, what slows down your WordPress site, and actionable steps that you can take to improve your WordPress speed immediately.
我们试图涵盖所有内容,包括为什么速度如此重要,什么会使您的WordPress网站变慢,以及您可以采取的可行步骤以立即提高WordPress速度。
To make it easy, we have created a table of contents to help you navigate through our ultimate guide to speeding up your WordPress site.
为简单起见,我们创建了一个目录,以帮助您浏览我们的终极指南,以加快WordPress网站的速度。
目录 (Table of Contents)
Basics of WordPress Performance
WordPress性能基础
- Why Speed is Important for your WordPress Site?为什么速度对您的WordPress网站很重要?
- How to Check Your WordPress Website Speed?如何检查您的WordPress网站速度?
- What Slows Down Your WordPress Website?是什么让您的WordPress网站慢下来?
- Importance of Good WordPress Hosting好的WordPress托管的重要性
Speeding Up WordPress in Easy Steps (No Coding)
通过简单的步骤加快WordPress(无需编码)
WordPress Performance Optimization Best Practices
WordPress性能优化最佳实践
- Keep Your WordPress Site Updated保持您的WordPress网站更新
- Optimize Background Processes优化后台流程
- Use Excerpts on Homepage and Archives使用主页和存档中的摘录
- Split Comments into Pages将评论分成页面
- Use a Content Delivery Network (CDN)使用内容传送网络(CDN)
- Don’t Upload Audio/Video Files Directly to WordPress不要将音频/视频文件直接上传到WordPress
- Use a Theme Optimized For Speed使用针对速度优化的主题
- Use Faster Plugins使用更快的插件
Fine-Tuning WordPress for Speed (Advanced)
精调WordPress以提高速度(进阶)
- Split Long Posts into Pages将长帖子拆分为页面
- Reduce External HTTP Requests减少外部HTTP请求
- Reduce Database Calls减少数据库调用
- Optimize WordPress Database优化WordPress数据库
- Limit Post Revisions限制帖子修订
- Disable Hotlinking and Leeching of Your Content禁用内容的热链接和获取
- Use Lazy Loading if Needed如果需要,请使用延迟加载
- Use DNS Level Website Firewall使用DNS级网站防火墙
- Fix HTTPS/SSL Errors without Plugin修复不带插件的HTTPS / SSL错误
- Use Latest PHP Version使用最新PHP版本
为什么速度对您的WordPress网站很重要? (Why Speed is Important for Your WordPress Site?)
Studies show that from 2000 to 2016, the average human attention span has dropped from 12 seconds to 7 seconds.
研究表明,从2000年到2016年,人类的平均注意力跨度从12秒降至7秒。
What does this mean for you as a website owner?
作为网站所有者,这对您意味着什么?
You have very little time to show users your content and convince them to stay on your website.
您几乎没有时间向用户显示您的内容并说服他们留在您的网站上。
A slow website means users will potentially leave your website before it even loads.
网站速度慢意味着用户有可能在加载之前离开您的网站。
According to a StrangeLoop case study that involved Amazon, Google, and other larger sites, a 1 second delay in page load time can lead to 7% loss in conversions, 11% fewer page views, and 16% decrease in customer satisfaction.
根据涉及亚马逊,谷歌和其他大型网站的StrangeLoop案例研究,页面加载时间延迟1秒可导致7%的转换损失,11%的页面浏览量减少和16%的客户满意度下降。
![How speed affects your website How speed affects your website](https://i-blog.csdnimg.cn/blog_migrate/1c2d5b095ef3b8740b232deb19b41f86.png)
On top of that, Google and other search engines have already started penalizing slower websites by pushing them down in the search results which means lower traffic for slow websites.
最重要的是,Google和其他搜索引擎已经开始通过在搜索结果中压低速度较慢的网站来对其进行惩罚,这意味着速度较慢的网站的流量会减少。
To sum it all up, if you want more traffic, subscribers, and revenue from your website, then you must make your WordPress website FAST!
综上所述,如果您想从您的网站获得更多的流量,订阅者和收入,那么您必须使WordPress网站速度更快!
如何检查您的WordPress网站速度? (How to Check Your WordPress Website Speed?)
Often beginners think that their website is OK just because it doesn’t feel slow on their computer. That’s a HUGE mistake.
通常,初学者认为他们的网站还可以,只是因为它在计算机上的运行速度并不慢。 那是一个巨大的错误。
Since you frequently visit your own website, modern browsers like Chrome store your website in the cache and automatically prefetch it as soon as you start typing an address. This makes your website load almost instantly.
由于您经常访问自己的网站,因此Chrome之类的现代浏览器会将您的网站存储在缓存中,并在您开始输入地址后立即自动将其预取。 这使您的网站几乎立即加载。
However, a normal user who is visiting your website for the first time may not have the same experience.
但是,初次访问您的网站的普通用户可能没有相同的体验。
In fact, users in different geographical locations will have a completely different experience.
实际上,不同地理位置的用户将拥有完全不同的体验。
This is why we recommend that you test your website speed using a tool like IsItWP’s WordPress speed test.
这就是为什么我们建议您使用IsItWP的WordPress speed test之类的工具测试网站速度的原因。
It is a free online tool that allows you to test your website’s speed.
它是一个免费的在线工具,可让您测试网站的速度。
![IsItWP speed test tool IsItWP speed test tool](https://i-blog.csdnimg.cn/blog_migrate/f221fcdbd5ccc5fcd9416e3a20fcf584.png)
After you run your website speed test, you might be wondering what’s a good website speed that I should aim for?
运行网站速度测试后,您可能想知道我应该追求的良好网站速度?
A good page load time is under 2 seconds.
好的页面加载时间应少于2秒。
However, the faster you can make it, the better it is. A few milliseconds of improvements here and there can add up to shaving off half or even a full second from your load time.
但是,制作速度越快越好。 在这里和那里进行的几毫秒改进总共可以将您的加载时间缩短一半甚至整整一秒。
[ 返回页首↑ ]
是什么让您的WordPress网站慢下来? (What Slows Down Your WordPress Website?)
Your speed test report will likely have multiple recommendations for improvement. However, most of that is technical jargon which is hard for beginners to understand.
您的速度测试报告将可能有多项改进建议。 但是,大多数都是技术术语,初学者很难理解。
Learning what slows down your website is the key to improving performance and making smarter long-term decisions.
了解什么会使网站变慢,这是提高性能和做出更明智的长期决策的关键。
The primary causes for a slow WordPress website are:
WordPress网站运行缓慢的主要原因是:
- Web Hosting – When your web hosting server is not properly configured it can hurt your website speed.虚拟主机 –如果没有正确配置虚拟主机服务器,则可能会损害您的网站速度。
- WordPress Configuration – If your WordPress site is not serving cached pages, then it will overload your server thus causing your website to be slow or crash entirely.WordPress配置 –如果您的WordPress网站不提供缓存的页面,则它将使您的服务器超载,从而导致您的网站运行缓慢或完全崩溃。
- Page Size – Mainly images that aren’t optimized for web.页面大小 –主要是未针对Web优化的图像。
- Bad Plugins – If you’re using a poorly coded plugin, then it can significantly slow down your website.错误的插件 –如果您使用的插件编码不正确,则可能会大大降低您的网站速度。
- External scripts – External scripts such as ads, font loaders, etc can also have a huge impact on your website performance.外部脚本 –广告,字体加载器等外部脚本也会对您的网站性能产生巨大影响。
Now that you know what slows down your WordPress website, let’s take a look at how to speed up your WordPress website.
现在您知道了使WordPress网站变慢的原因,让我们看一下如何加快WordPress网站的速度。
好的WordPress托管的重要性 (Importance of Good WordPress Hosting)
Your WordPress hosting service plays an important role in website performance. A good shared hosting provider like Bluehost or Siteground take the extra measures to optimize your website for performance.
您的WordPress托管服务在网站性能中起着重要作用。 诸如Bluehost或Siteground之类的良好共享托管服务提供商会采取额外措施来优化您的网站的性能。
However, on shared hosting you share the server resources with many other customers. This means that if your neighboring site gets a lot of traffic, then it can impact the entire server performance which in turn will slow down your website.
但是,在共享主机上,您与许多其他客户共享服务器资源。 这意味着,如果您的邻近站点获得大量流量,则可能会影响整个服务器的性能,进而降低您的站点速度。
On the other hand, using a managed WordPress hosting service give you the most optimized server configurations to run WordPress. Managed WordPress hosting companies also offer automatic backups, automatic WordPress updates, and more advanced security configurations to protect your website.
另一方面,使用托管的WordPress托管服务可为您提供最优化的服务器配置以运行WordPress。 托管WordPress托管公司还提供自动备份,自动WordPress更新以及更高级的安全配置,以保护您的网站。
We recommend WPEngine as our preferred managed WordPress hosting provider. They’re also the most popular one in the industry. (See our special WPEngine coupon).
我们建议WPEngine作为我们首选的托管WordPress托管提供商。 它们也是业内最受欢迎的产品。 (请参阅我们的WPEngine特殊优惠券 )。
[ 返回页首↑ ]
通过简单的步骤加快WordPress(无需编码) (Speeding Up WordPress in Easy Steps (No Coding))
We know that making changes to your website configuration can be a terrifying thought for beginners, especially if you’re not a tech-geek.
我们知道,对您的网站配置进行更改可能会使初学者感到恐惧,特别是如果您不是技术极客的话。
But don’t worry, you’re not alone. We have helped thousands of WordPress users improve their WordPress performance.
但请放心,您并不孤单。 我们已经帮助成千上万的WordPress用户提高了WordPress的性能。
We will show you how you can speed up your WordPress site with just a few clicks (no coding required).
我们将向您展示如何仅需单击几下即可加快WordPress网站的速度(无需编码)。
If you can point-and-click, then you can do this!
如果您可以单击并单击,就可以这样做!
安装WordPress缓存插件 (Install a WordPress Caching Plugin)
WordPress pages are “dynamic.” This means they’re built on the fly every time someone visits a post or page on your website.
WordPress页面是“动态的”。 这意味着每次有人访问您网站上的帖子或页面时,它们都是动态构建的。
To build your pages, WordPress has to run a process to find the required information, put it all together, and then display it to your user.
为了构建您的页面,WordPress必须运行一个过程来查找所需的信息,将所有信息放在一起,然后将其显示给您的用户。
This process involves a lot of steps, and it can really slow down your website when you have multiple people visiting it at once.
此过程涉及许多步骤,当您同时有多个人访问它时,它确实会使您的网站变慢。
That’s why we recommend every WordPress site use a caching plugin. Caching can make your WordPress site anywhere from 2x to 5x faster.
因此,我们建议每个WordPress网站都使用缓存插件。 缓存可以使您的WordPress网站的速度提高2到5倍。
Here’s how it works.
运作方式如下。
Instead of going through the whole page generation process every time, your caching plugin makes a copy of the page after the first load, and then serves that cached version to every subsequent user.
您的缓存插件无需每次都完成整个页面生成过程,而是在首次加载后制作页面副本,然后将该缓存的版本提供给每个后续用户。
![Page caching Page caching](https://i-blog.csdnimg.cn/blog_migrate/b650559ec3f22a212209f2ff534d3048.png)
As you can see in the graphics above, when a user visits your WordPress site, your server retrieves information from a MySQL database and your PHP files. It then puts it all together into HTML content which is served to the user.
如您在上图中所看到的,当用户访问WordPress网站时,您的服务器从MySQL数据库和PHP文件中检索信息。 然后将所有内容放到一起提供给用户HTML内容中。
It’s a long process, but you can skip a lot of it when you use caching instead.
这是一个漫长的过程,但是当您使用缓存时,可以跳过很多过程。
There are a lot of good WordPress caching plugins available, but we recommend using either WP Rocket (premium) or WP Super Cache (free) plugin.
有很多不错的WordPress缓存插件 ,但是我们建议使用WP Rocket (高级)或WP Super Cache (免费)插件。
Check out our step by step guide on how to install and setup WP Super Cache on your WordPress site. It’s not difficult to set up, and your visitors will notice the difference.
查看有关如何在WordPress网站上安装和设置WP Super Cache的分步指南。 设置并不难,您的访客会注意到其中的区别。
Many WordPress hosting companies like Bluehost and SiteGround offer caching solutions as well.
许多WordPress托管公司(例如Bluehost和SiteGround)也提供缓存解决方案。
SiteGround SuperCacher
SiteGround SuperCacher
If you are using SiteGround then login to hosting cPanel and enable SuperCacher under ‘Site improvement tools’.
如果您使用的是SiteGround,则登录到托管cPanel并在“站点改进工具”下启用SuperCacher。
![Supercacher Supercacher](https://i-blog.csdnimg.cn/blog_migrate/ce0f407e765637a1256055511feb4ea4.png)
After that, you will need to install and activate the SG Optimizer plugin in WordPress to manage SuperCacher settings.
之后,您将需要在WordPress中安装并激活SG Optimizer插件以管理SuperCacher设置。
Bluehost Caching
Bluehost缓存
If you are using Bluehost, then go to My Sites » Performance section to turn on caching.
如果您使用的是Bluehost ,请转到“ 我的网站”»“性能”部分以打开缓存。
![Turning on Caching in Bluehost Turning on Caching in Bluehost](https://i-blog.csdnimg.cn/blog_migrate/ccc159985e79258088b7366376c86db1.png)
If you’re using a managed WordPress hosting provider, then you don’t need a caching plugin because it is built-in and turned on by default.
如果您使用的是托管WordPress托管提供程序,则不需要缓存插件,因为该插件是内置的并且默认情况下处于启用状态。
Bonus: You can combine caching plugins with a web application firewall like CloudFlare or Sucuri for maximum performance boost.
奖励:您可以将缓存插件与Web应用程序防火墙(例如CloudFlare或Sucuri)结合使用,以最大程度地提高性能。
[ 返回页首↑ ]
优化图像以提高速度 (Optimize Images for Speed)
![Optimizing images for speed Optimizing images for speed](https://i-blog.csdnimg.cn/blog_migrate/b2ff086bf9efaaa50d3b4706d377eb94.png)
Images bring life to your content and help boost engagement. Researchers have found that using colored visuals makes people 80% more likely to read your content.
图像使您的内容栩栩如生,并有助于提高参与度。 研究人员发现,使用彩色视觉效果使人们阅读内容的可能性提高了80%。
However, if your images aren’t optimized, then they could be hurting more than helping. In fact, non-optimized images are one of the most common speed issues that we see on beginner websites.
但是,如果您的图像没有经过优化,那么它们可能会比帮助有所伤害。 实际上,未经优化的图像是我们在初学者网站上看到的最常见的速度问题之一。
Before you upload a photo directly from your phone or camera, we recommend that you use photo editing software to optimize your images for the web.
在直接从手机或相机上传照片之前,建议您使用照片编辑软件来优化网络图像。
In their original formats, these photos can have huge file sizes. But based on the image file format and the compression you choose in your editing software, you can decrease your image size by up to 5x.
这些照片在原始格式下可能具有很大的文件大小。 但是,根据图像文件格式和在编辑软件中选择的压缩率 ,您最多可以将图像尺寸减小5倍。
At WPBeginner, we only use two image formats: JPEG and PNG.
在WPBeginner,我们仅使用两种图像格式:JPEG和PNG。
Now you might be wondering: what’s the difference?
现在您可能想知道:有什么区别?
Well, PNG image format is uncompressed. When you compress an image it loses some information, so an uncompressed image will be higher quality with more detail. The downside is that it’s a larger file size, so it takes longer to load.
好吧, PNG图像格式是未压缩的。 压缩图像时,它会丢失一些信息,因此未压缩的图像将具有更高的质量和更多细节。 缺点是文件较大,因此加载时间更长。
JPEG, on the other hand, is a compressed file format which slightly reduces image quality, but it’s significantly smaller in size.
另一方面, JPEG是一种压缩的文件格式,虽然略有降低图像质量,但尺寸明显较小。
So how do we decide which image format to choose?
那么我们如何决定选择哪种图像格式?
- If our photo or image has a lot of different colors, then we use JPEG. 如果我们的照片或图像有很多不同的颜色,则我们使用JPEG。
- If it’s a simpler image or we need a transparent image, then we use PNG. 如果是简单图像或需要透明图像,则可以使用PNG。
The majority of our images are JPEGs.
我们的大多数图像都是JPEG。
Below is a comparison chart of the file sizes and different compression tool that we could have used for the StrangeLoop image used above.
下面是我们可以用于上面使用的StrangeLoop图像的文件大小和不同压缩工具的比较表。
![Image speed chart Image speed chart](https://i-blog.csdnimg.cn/blog_migrate/d97f47445f073fc2b7148a842bb9493a.png)
As you can see in the chart, the image format you use can make a HUGE difference in website performance.
从图表中可以看出,您使用的图像格式可以大大改善网站的性能。
For details on exactly how to optimize your images using Photoshop and other popular editing tools, without sacrificing quality, see our step by step guide on how to save images optimized for web.
有关在不牺牲质量的情况下如何使用Photoshop和其他流行的编辑工具精确优化图像的详细信息,请参阅有关如何保存针对Web优化的图像的逐步指南。
[ 返回页首↑ ]
WordPress性能优化最佳实践 (WordPress Performance Optimization Best Practices)
After installing a caching plugin and optimizing your images, you’ll notice your site will start loading a lot faster.
在安装了缓存插件并优化了图像之后,您会发现您的站点将开始更快地加载。
But if you really want to keep your website as fast as possible, you’ll need to use the best practices listed below.
但是,如果您确实想使您的网站保持尽可能快的速度,则需要使用下面列出的最佳做法。
These tips aren’t too technical, so you don’t need to know any code to implement them. But using them will prevent common problems that will slow down your website.
这些技巧不是太技术性,因此您不需要知道任何代码即可实现它们。 但是使用它们可以防止会导致您的网站变慢的常见问题。
保持您的WordPress网站更新 (Keep Your WordPress Site Updated)
![Keep WordPress updated Keep WordPress updated](https://i-blog.csdnimg.cn/blog_migrate/8b1c69ebb58a30d4ae8b534cc7711efc.png)
As a well maintained open source project, WordPress is updated frequently. Each update will not only offer new features but it will also fix security issues and bugs. Your WordPress theme and plugins may have regular updates, too.
作为一个维护良好的开源项目,WordPress会经常更新。 每个更新不仅将提供新功能,还将修复安全问题和错误。 您的WordPress主题和插件也可能会定期更新。
As a website owner, it’s your responsibility to keep your WordPress site, theme, and plugins updated to the latest versions. Not doing so may make your site slow and unreliable, and make you vulnerable to security threats.
作为网站所有者,您有责任将WordPress网站,主题和插件更新为最新版本。 不这样做可能会使您的网站运行缓慢且不可靠,并使您容易受到安全威胁的攻击。
For more details on the importance of updates, see our article on why you should always use the latest WordPress version.
有关更新重要性的更多详细信息,请参阅我们的文章,为什么您应该始终使用最新的WordPress版本 。
[ 返回页首↑ ]
优化后台流程 (Optimize Background Processes)
Background processes in WordPress are scheduled tasks that run in the background of your WordPress site. Following are some examples of background tasks that run on a WordPress site:
WordPress中的后台进程是在WordPress网站后台运行的计划任务。 以下是在WordPress网站上运行的后台任务的一些示例:
- WordPress Backup plugin tasks WordPress备份插件任务
- WordPress cron jobs to publish scheduled posts WordPress cron作业发布预定的帖子
- WordPress cron jobs to check for updates WordPress cron作业以检查更新
- Search engines and other crawlers trying to fetch content 搜索引擎和其他尝试抓取内容的抓取工具
Tasks like cron jobs for scheduled posts and updates have minimal impact on website performance.
计划的帖子和更新的cron任务之类的任务对网站性能的影响最小。
However, other background processes like backup plugins and excessive crawling by search engines can slow down a website.
但是,其他后台进程(如备份插件和搜索引擎过度爬网)可能会使网站变慢。
For backup plugins, you need to make sure that your WordPress backup plugin only run during low traffic time on your website. You also need to adjust the frequency of backups and data that needs to be backed up.
对于备份插件,您需要确保您的WordPress备份插件仅在网站访问量较低时运行。 您还需要调整备份和需要备份的数据的频率。
For example, if you are creating a complete daily backup while you only publish new content twice a week, then you need to adjust that.
例如,如果您要创建一个完整的每日备份,而您每周仅发布两次新内容,则需要进行调整。
If you want more frequent backups such as real-time backups, then we recommend using a SaaS solution so you’re not taxing your server.
如果您想要更频繁的备份(例如实时备份),那么我们建议您使用SaaS解决方案,以免增加服务器负担。
As for crawling, you need to keep an eye on your crawl reports in Google Search console. Frequent crawls that are ending up in errors can cause your website to slow down or become unresponsive.
至于抓取,您需要在Google Search Console中关注抓取报告。 频繁出现的错误爬网可能会导致您的网站运行缓慢或无法响应。
See our complete Google Search Console guide for beginners to learn how to adjust crawl rate.
请参阅面向初学者的完整Google Search Console指南 ,以了解如何调整抓取速度。
[ 返回页首↑ ]
使用主页和存档中的摘录 (Use Excerpts on Homepage and Archives)
![Using excerpts Using excerpts](https://i-blog.csdnimg.cn/blog_migrate/9d34b0cc153825fa4bb0f25a136a3c75.png)
By default, WordPress displays the full content of each article on your homepage and archives. This means your homepage, categories, tags, and other archive pages will all load slower.
默认情况下,WordPress在您的首页和档案中显示每篇文章的全部内容。 这意味着您的主页,类别,标签和其他存档页面的加载速度都会变慢。
Another disadvantage of showing full articles on these pages is that users don’t feel the need to visit the actual article. This can reduce your pageviews, and the time your users spend on your site.
在这些页面上显示完整文章的另一个缺点是用户不需要访问实际文章。 这可以减少您的综合浏览量,并减少用户在您的网站上花费的时间。
In order to speed up your loading times for archive pages, you can set your site to display excerpts instead of the full content.
为了加快存档页面的加载时间,可以将站点设置为显示摘录而不是全部内容。
You can navigate to Settings » Reading and select “For each article in a feed, show: Summary” instead of “Full Text.”
您可以导航至设置»阅读,然后选择“对于供稿中的每篇文章,显示:摘要”,而不是“全文”。
![Display excerpts instead of full text to boost WordPress speed Display excerpts instead of full text to boost WordPress speed](https://i-blog.csdnimg.cn/blog_migrate/758fd18bd427ce9909dd205d1b5529dd.png)
For more details on the pros and cons of displaying summaries, see our article on full post vs summary (excerpt) in your WordPress archive pages.
有关显示摘要的优缺点的更多详细信息,请参阅WordPress存档页面中有关完整文章与摘要(摘录)的文章。
[ 返回页首↑ ]
将评论分成页面 (Split Comments into Pages)
![Paginate comments Paginate comments](https://i-blog.csdnimg.cn/blog_migrate/07179b9a6076d0763368a6bcc2c180bc.png)
Getting lots of comments on your blog posts? Congratulations! That’s a great indicator of an engaged audience.
在您的博客文章上得到很多评论 ? 恭喜你! 这很好地表明了参与的受众。
But the downside is, loading all those comments can impact your site’s speed.
但是不利的是,加载所有这些评论会影响您网站的速度。
WordPress comes with a built-in solution for that. Simply go to Settings » Discussion and check the box next to the “Break comments into pages” option.
WordPress附带了一个内置的解决方案。 只需转到“设置”»“讨论”,然后选中“将注释插入页面中”选项旁边的框。
![Break comments in pages Break comments in pages](https://i-blog.csdnimg.cn/blog_migrate/12825a835b3ad9bd469aa3fbcd5c3cb6.png)
For more detailed instructions, see our guide on how to paginate comments in WordPress.
有关更多详细说明,请参阅有关如何在WordPress中对注释进行分页的指南。
[ 返回页首↑ ]
使用内容传送网络(CDN) (Use a Content Delivery Network (CDN))
Remember how we mentioned above that users in different geographical locations may experience different loading times on your site?
还记得我们上面提到的那样,不同地理位置的用户在您的网站上可能会经历不同的加载时间吗?
That’s because the location of your web hosting servers can have an impact on your site speed.
这是因为您的网络托管服务器的位置可能会影响您的网站速度。
For example, let’s say your web hosting company has its servers in the United States. A visitor who’s also in the United States will generally see faster loading times than a visitor in India.
例如,假设您的网络托管公司的服务器在美国。 同样在美国的访问者通常会比在印度的访问者看到更快的加载时间。
Using a Content Delivery Network (CDN), can help to speed up loading times for all of your visitors.
使用内容分发网络(CDN),可以帮助加快所有访问者的加载时间。
A CDN is a network made up of servers all around the world. Each server will store “static” files used to make up your website.
CDN是由世界各地的服务器组成的网络。 每个服务器将存储用于组成您的网站的“静态”文件。
These static files include unchanging files such as images, CSS, and JavaScript, unlike your WordPress pages which are “dynamic” as explained above.
这些静态文件包括不变的文件,例如图像,CSS和JavaScript,这与您的WordPress页面不同(如上所述)是“动态的”。
When you use a CDN, every time a user visits your website they are served those static files from whichever server is closest to them. Your own web hosting server will also be faster since the CDN is doing a lot of the work.
当您使用CDN时,每次用户访问您的网站时,都会向他们提供最接近他们的服务器中的那些静态文件。 由于CDN正在进行很多工作,因此您自己的Web托管服务器也将更快。
You can see how it works in this infographic.
您可以在此信息图中查看其工作方式。
We use recommend using StackPath CDN. We have been using MaxCDN on all our websites which is now also part of StackPath.
我们建议使用StackPath CDN 。 我们一直在使用MaxCDN我们所有的网站,这是现在还StackPath的一部分。
It works well with WordPress websites and compliments your existing WordPress caching plugins for even faster loading times.
它可以与WordPress网站很好地配合使用,并且可以补充您现有的WordPress缓存插件,从而缩短加载时间。
[ 返回页首↑ ]
不要将音频/视频文件直接上传到WordPress (Don’t Upload Audio/Video Files Directly to WordPress)
![Use video hosting services like YouTube Use video hosting services like YouTube](https://i-blog.csdnimg.cn/blog_migrate/b4629c8dfc93b2a68b502ff1bff61a87.png)
You can directly upload audio and video files to your WordPress site, and it will automatically display them in an HTML5 player…
您可以将音频和视频文件直接上传到WordPress网站,它会自动在HTML5播放器中显示它们…
But you should NEVER do that!
但是你永远都不要那样做!
Hosting audio and videos will cost you bandwidth. You could be charged overage fees by your web hosting company, or they may even shut down your site altogether, even if your plan includes “unlimited” bandwidth.
托管音频和视频将占用您的带宽。 您的网络托管公司可能会向您收取超额费用,或者即使您的计划包括“无限”带宽,它们甚至可能会完全关闭您的网站。
Hosting large media files also increases your backup sizes tremendously, and makes it difficult for you to restore WordPress from backup.
托管大型媒体文件还极大地增加了备份大小,并使您难以从备份还原WordPress 。
Instead, you should use an audio and video hosting service like YouTube, Vimeo, DailyMotion, SoundCloud, etc., and let them take care of the hard work. They have the bandwidth for it!
相反,您应该使用音频和视频托管服务,例如YouTube, Vimeo ,DailyMotion,SoundCloud等,并让他们照顾自己的辛苦工作。 他们有足够的带宽!
WordPress has a built-in video embed feature, so you can copy and paste your video’s URL directly into your post and it will embed automatically.
WordPress具有内置的视频嵌入功能,因此您可以将视频的URL直接复制并粘贴到帖子中,它将自动嵌入。
Find out more details on how it works in our guide on embedding videos in WordPress.
在我们的将视频嵌入WordPress的指南中找到有关其工作原理的更多详细信息。
If you are making a podcast website with WordPress, then we recommend podcast hosting service Blubrry for the best performance.
如果您使用WordPress创建播客网站 ,那么我们建议使用播客托管服务Blubrry以获得最佳性能。
[ 返回页首↑ ]
使用针对速度优化的主题 (Use a Theme Optimized For Speed)
![Choose a theme optimized for speed Choose a theme optimized for speed](https://i-blog.csdnimg.cn/blog_migrate/bbc5a507c0bb1410258b08f8853f5790.png)
When selecting a theme for your website, it’s important to pay special attention to speed optimization. Some beautiful and impressive-looking themes are actually poorly coded and can slow your site way down.
为您的网站选择主题时,特别要注意速度优化,这一点很重要。 实际上,一些美观且令人印象深刻的主题编码不正确,可能会使您的网站变慢。
It’s usually better to go with a simpler theme than to choose a theme that’s bloated with complex layouts, flashy animations, and other unnecessary features. You can always add those features using quality WordPress plugins.
通常,选择一个简单的主题比选择一个具有复杂布局,浮华动画和其他不必要功能的主题要好。 您始终可以使用优质的WordPress插件添加这些功能。
Premium WordPress theme shops like StudioPress, Themify, CSSIgniter offer themes that are well coded and optimized for speed. You can also check out our article on selecting the perfect WordPress theme for advice on what to look for.
诸如StudioPress , Themify , CSSIgniter之类的高级WordPress主题商店提供了经过精心编码和针对速度进行了优化的主题。 您还可以查看有关选择理想WordPress主题的文章, 以获取所需的建议。
Before you activate your new theme, see our guide on how to properly switch your WordPress theme for a smooth transition.
在激活新主题之前,请参阅我们的指南, 了解如何正确切换WordPress主题以实现平稳过渡。
[ 返回页首↑ ]
使用更快的插件 (Use Faster Plugins)
![Choose faster plugins for your website Choose faster plugins for your website](https://i-blog.csdnimg.cn/blog_migrate/2c29cd0aeed888d188c532257dadf85b.png)
Poorly coded WordPress plugins often load too much bloat whether your site needs it or not. This increases your page load speed and slows down your site.
无论您的站点是否需要,编码不正确的WordPress插件通常都会使页面膨胀过多。 这样可以提高页面加载速度,并降低网站速度。
To help you choose the best plugins, we often publish our expert pick of best WordPress plugin showcases. We pay special attention to ease of use, user experience, and most importantly performance.
为了帮助您选择最佳的插件,我们经常发布专家精选的最佳WordPress插件展示。 我们特别注意易用性,用户体验以及最重要的性能。
Following are some of our picks for the most common WordPress plugin categories.
以下是一些最常见的WordPress插件类别的精选。
- WPForms – Fastest and most beginner friendly WPForms –最快,最适合初学者的WordPress contact form plugin for WordPress. 联络表单插件 。
- Soliloquy – If you want to add sliders to your site, then Soliloquy is the Soliloquy –如果您想向您的站点添加滑块,那么就性能和功能而言,Sololoquy是best WordPress slider plugin in terms of performance and features. 最好的WordPress滑块插件 。
- Envira Gallery – Photo gallery plugins can also slow down WordPress. We ran the tests and found Envira Gallery to be the Envira Gallery –照片库插件也会降低WordPress的速度。 我们进行了测试,发现Envira Gallery是WordPress fastest photo gallery plugin for WordPress.最快的照片库插件 。
- Shared Counts – Social media plugins load additional scripts and not so gracefully. Shared Counts is one of the fastest Social media plugins for WordPress. 共享计数 –社交媒体插件会加载其他脚本,而并非如此。 Shared Counts是WordPress最快的社交媒体插件之一。
Apart from our own recommendations, you can run your own tests. Simply run speed tests before and after installing a plugin to compare its impact on performance.
除了我们自己的建议外,您还可以运行自己的测试。 只需在安装插件之前和之后进行速度测试,以比较其对性能的影响。
[ 返回页首↑ ]
精调WordPress以提高速度(进阶) (Fine-Tuning WordPress for Speed (Advanced))
By using the WordPress optimization best practices and basic speed tips listed above, you should see a big improvement in your site’s loading times.
通过使用上面列出的WordPress优化最佳实践和基本速度提示,您应该会看到网站的加载时间有了很大的改善。
But every fraction of a second counts. If you want to get the very fastest speed possible, then you’ll want to make a few more changes.
但是每一分之一秒都很重要。 如果您想获得最快的速度,那么您将需要进行一些其他更改。
The following tips are a little more technical, with some requiring you to modify your site files or have a basic understanding of PHP. You’ll want to make sure to backup your site first just in case.
以下技巧有些技术性,其中一些技巧要求您修改站点文件或对PHP有基本的了解。 您需要确保首先备份站点 ,以防万一。
将长帖子拆分为页面 (Split Long Posts into Pages)
![Split long posts in pages Split long posts in pages](https://i-blog.csdnimg.cn/blog_migrate/b240c2e310445a9df092c8c39b4910db.png)
Readers tend to love blog posts that are longer and more in-depth. Longer posts even tend to rank higher in search engines.
读者往往会喜欢更长且更深入的博客文章。 较长的帖子在搜索引擎中的排名甚至更高。
But if you’re publishing long-form articles with lots of images, it could be hurting your loading times.
但是,如果您要发布包含大量图像的长篇文章,则可能会损害您的加载时间。
Instead, consider splitting up your longer posts into multiple pages.
相反,请考虑将较长的帖子分成多个页面。
WordPress comes with built-in functionality to do that. Simply add the <!––nextpage––>
tag in your article where you want to split it into next page. Do that again if you want to split the article on to the next page as well.
WordPress带有内置功能来做到这一点。 只需在您想将其拆分为下一页的文章中添加<!––nextpage––>
标记即可。 如果您也想将文章拆分到下一页,请再次执行此操作。
For more detailed instructions, see our tutorial on post pagination – how to split WordPress posts into multiple pages.
有关更多详细说明,请参阅我们的分页教程-如何将WordPress帖子分成多个页面 。
[ 返回页首↑ ]
减少外部HTTP请求 (Reduce External HTTP Requests)
![Reduce cross-domain HTTP requests Reduce cross-domain HTTP requests](https://i-blog.csdnimg.cn/blog_migrate/91ce27e995b1d7f7f773de00f9121c38.png)
Many WordPress plugins and themes load all kinds of files from other websites. These files can include scripts, stylesheets, and images from external resources like Google, Facebook, analytics services, and so on.
许多WordPress插件和主题可以从其他网站加载各种文件。 这些文件可以包括脚本,样式表和来自外部资源(如Google,Facebook,分析服务等)的图像。
It’s ok to use a few of these. Many of these files are optimized to load as quickly as possible, so it’s faster than hosting them on your own website.
可以使用其中一些。 这些文件中的许多文件都经过了优化,可以尽快加载,因此比在您自己的网站上托管它们要快。
But if your plugins are making a lot of these requests, then it could slow down your website significantly.
但是,如果您的插件发出了很多此类请求,则可能会大大降低您的网站速度。
You can reduce all these external HTTP requests by disabling scripts and styles or merging them into one file. Here’s a tutorial on how to disable your plugins’ CSS files and JavaScript.
您可以通过禁用脚本和样式或将它们合并到一个文件中来减少所有这些外部HTTP请求。 这是有关如何禁用插件CSS文件和JavaScript的教程。
[ 返回页首↑ ]
减少数据库调用 (Reduce Database Calls)
![Reduce database calls Reduce database calls](https://i-blog.csdnimg.cn/blog_migrate/02487a2a1e7929cdb00ad27ca255e30e.png)
Note: This step is a little more technical and will require basic knowledge of PHP and WordPress template files.
注意:此步骤有点技术性,需要PHP和WordPress模板文件的基础知识。
Unfortunately, there are a lot of poorly coded WordPress themes out there. They ignore WordPress standard practices and end up making direct database calls, or too many unnecessary requests to the database. This can really slow down your server by giving it too much work to do.
不幸的是,那里有很多编码错误的WordPress主题。 他们无视WordPress标准规范,最终直接进行数据库调用,或者对数据库进行了太多不必要的请求。 这样做会使您的服务器工作量过多,从而确实减慢了服务器的速度。
Even well-coded themes can have code that makes database calls just to get your blog’s basic information.
即使主题编码正确,也可以使用代码进行数据库调用,以获取博客的基本信息。
In this example, every time you see <?php
, that’s the start of a new database call:
在此示例中,每次看到<?php
,这就是新数据库调用的开始:
<html xmlns="http://www.w3.org/1999/xhtml" dir="<?php language_attributes(); ?>">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>
charset=<?php bloginfo('charset'); ?>" />
You can’t blame theme developers for that. They simply have no other way to find out what language your site is in.
您不能为此责怪主题开发人员。 他们只是没有其他方法来找出您的网站使用的语言。
But if you are customizing your site using a child theme, then you can replace these database calls with your specific information in order to reduce all those database calls.
但是,如果要使用子主题自定义站点,则可以使用特定信息替换这些数据库调用,以减少所有这些数据库调用。
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Review your parent theme for instances like this that can be easily replaced with static information.
查看您的父主题,以查找可以轻松替换为静态信息的实例。
[ 返回页首↑ ]
优化WordPress数据库 (Optimize WordPress Database)
![WordPress database optimization WordPress database optimization](https://i-blog.csdnimg.cn/blog_migrate/15d18a36ecaf50c3c26a0aa8eb683a3b.png)
After using WordPress for a while, your database will have lots of information that you probably don’t need any more. For improved performance, you can optimize your database to get rid of all that unnecessary information.
在使用WordPress一段时间后,您的数据库将拥有很多您可能不再需要的信息。 为了提高性能,您可以优化数据库以消除所有不必要的信息。
This can be easily managed with the WP-Sweep plugin. It allows you to clean your WordPress database by deleting things like trashed posts, revisions, unused tags, etc. It will also optimize your database’s structure with just a click.
可以使用WP-Sweep插件轻松管理。 它允许您通过删除已删除帖子,修订,未使用的标签等内容来清理WordPress数据库。它还可以通过单击来优化数据库的结构。
See our guide on how to optimize and clean up your WordPress database for improved performance.
请参阅我们的指南,以了解如何优化和清理WordPress数据库以提高性能 。
[ 返回页首↑ ]
限制帖子修订 (Limit Post Revisions)
![Limit post revisions in WordPress Limit post revisions in WordPress](https://i-blog.csdnimg.cn/blog_migrate/68224f7e37751acc1940df61bd591b83.png)
Post revisions take up space in your WordPress database. Some users believe that revisions can also affect some database queries run by plugins. If the plugin doesn’t specifically exclude post revisions, it might slow down your site by searching through them unnecessarily.
修订后的版本占用了WordPress数据库中的空间。 一些用户认为修订也可能影响插件运行的某些数据库查询。 如果该插件未明确排除后期修订,则可能会通过不必要的搜索来减慢您的网站的速度。
You can easily limit the number of revisions WordPress keeps for each article. Simply add this line of code to your wp-config.php file.
您可以轻松限制WordPress对每篇文章进行的修订的数量。 只需将这行代码添加到wp-config.php文件中。
define( 'WP_POST_REVISIONS', 4 );
This code will limit WordPress to only save your last 4 revisions of each post or page, and discard older revisions automatically.
此代码将限制WordPress仅保存每个帖子或页面的最后4个修订,并自动丢弃较旧的修订。
[ 返回页首↑ ]
禁用内容的热链接和学习 (Disable Hotlinking and Leaching of Your Content)
![Prevent image theft in WordPress Prevent image theft in WordPress](https://i-blog.csdnimg.cn/blog_migrate/d3f2f50c7d061dc153b17448a43b716d.png)
If you’re creating quality content on your WordPress site, then the sad truth is that it’ll probably get stolen sooner or later.
如果您要在WordPress网站上创建高质量的内容,那么可悲的事实是它迟早会被盗。
One way this happens is when other websites serve your images directly from their URLs on your website, instead of uploading them to their own servers. In effect, they’re stealing your web hosting bandwidth, and you don’t get any traffic to show for it.
发生这种情况的一种方式是,其他网站直接从其网站上的URL提供您的图片,而不是将其上传到自己的服务器上。 实际上,它们正在窃取您的虚拟主机带宽,并且您没有得到任何流量显示。
Simply add this code to your .htaccess file to block hotlinking of images from your WordPress site.
只需将此代码添加到您的.htaccess文件中,即可阻止WordPress网站中图片的热链接。
#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?wpbeginner.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ – [NC,F,L]
Note: Don’t forget to change wpbeginner.com with your own domain.
注意:不要忘记用您自己的域更改wpbeginner.com。
You may also want to check our article showing 4 ways to prevent image theft in WordPress.
您可能还需要查看我们的文章,该文章显示了WordPress中防止图像盗窃的4种方法 。
Some content scraping websites automatically create posts by stealing your content from your RSS feed. You can check out our guide on preventing blog content scraping in WordPress for ways to deal with automated content theft.
一些内容抓取网站会通过从RSS feed中窃取您的内容来自动创建帖子。 您可以查看有关防止WordPress中的博客内容被抓取的指南,以找到自动内容盗窃的方法。
[ 返回页首↑ ]
如果需要,请使用延迟加载 (Use Lazy Loading if Needed)
![Use lazy loading in WordPress Use lazy loading in WordPress](https://i-blog.csdnimg.cn/blog_migrate/0e25013df1e4719303cd4c937d2241d6.png)
If you add many images, multiple video embeds, and photo galleries to your blog posts, then your site can benefit from lazy loading.
如果您在博客文章中添加了许多图像,多个视频嵌入和照片库,则您的站点可以从延迟加载中受益。
Instead of loading all your images and videos at once, lazy loading downloads only those that will be visible on the user’s screen. It replaces all other images and video embeds with a placeholder image.
延迟加载不是立即加载所有图像和视频,而是仅下载那些在用户屏幕上可见的图像和视频。 它将所有其他图像和视频嵌入替换为一个占位符图像。
As a user scrolls down, your website loads images that are now visible in the browser’s viewing area. You can lazy load images, videos, and even WordPress comments and gravatars.
当用户向下滚动时,您的网站将加载在浏览器查看区域中可见的图像。 您可以延迟加载图像,视频,甚至WordPress注释和gravatars。
For images, iframes, and videos, you can use the Lazy Load by WP Rocket plugin. For WordPress comments see our guide on how to lazy load comments in WordPress.
对于图像,iframe和视频,您可以使用WP Rocket的“ 延迟加载”插件。 对于WordPress评论,请参阅我们的指南, 了解如何在WordPress中延迟加载评论 。
[ 返回页首↑ ]
使用DNS级网站防火墙 (Use DNS Level Website Firewall)
![Use DNS level firewall Use DNS level firewall](https://i-blog.csdnimg.cn/blog_migrate/5129c1ae4d959871279e155614134bf0.png)
A WordPress firewall plugin helps you block brute force attacks, hacking attempts, and malware. However, not all firewall plugins are the same.
WordPress防火墙插件可帮助您阻止暴力攻击 ,黑客攻击和恶意软件。 但是,并非所有的防火墙插件都是相同的。
Some of them run on your website, this means attackers are already able to reach your web server before they get blocked. This is still effective for security, but not optimal for performance.
其中一些在您的网站上运行,这意味着攻击者已经可以在被阻止之前访问您的Web服务器。 这对于安全性仍然有效,但对于性能而言并非最佳。
This is why we recommend using a DNS level firewall like Sucuri or Cloudflare. These firewalls block maclious requests even before they reach your website.
这就是为什么我们建议使用DNS级别的防火墙(例如Sucuri或Cloudflare)的原因 。 这些防火墙甚至可以阻止恶意请求到达您的网站。
[ 返回页首↑ ]
修复不带插件的HTTPS / SSL错误 (Fix HTTPS/SSL Errors without Plugin)
![Using inspect tool to fix mixed content error Using inspect tool to fix mixed content error](https://i-blog.csdnimg.cn/blog_migrate/ffd32a350837b2bf51c6999ef94ae51a.png)
If you are switching your site to HTTPS/SSL, then it is likely that you may run across mixed content errors.
如果将站点切换为HTTPS / SSL ,则可能会遇到混合内容错误 。
The easiest way to fix this is by installing a plugin like Really Simple SSL. However, the problem is that these plugins catch all URLs first, then change them to HTTPS before sending them to user’s browsers.
解决此问题的最简单方法是安装类似Really Simple SSL的插件。 但是,问题在于这些插件会先捕获所有URL,然后再将其更改为HTTPS,然后再将其发送到用户的浏览器。
This has a small but noticeable performance impact. You can reduce this by manually fixing all URLs. For more details see our article on how to fix common SSL issues in WordPress.
这对性能的影响很小,但很明显。 您可以通过手动修复所有URL来减少这种情况。 有关更多详细信息,请参阅有关如何解决WordPress中常见SSL问题的文章。
[ 返回页首↑ ]
使用最新PHP版本 (Use Latest PHP Version)
WordPress is mainly written in the PHP programming language. It is a server side language, which means it is installed and runs on your hosting server.
WordPress主要是用PHP编程语言编写的。 它是一种服务器端语言,这意味着它已在主机服务器上安装并运行。
All good WordPress hosting companies use the most stable PHP version on their servers. However, it is possible that your hosting company is running a slightly older PHP version.
所有好的WordPress托管公司都在其服务器上使用最稳定PHP版本。 但是,您的托管公司可能正在运行稍旧PHP版本。
The newer PHP 7 is two times faster than its predecessors. That’s a huge performance boost that your website must take advantage of.
较新PHP 7比以前的版本快两倍。 这是您的网站必须利用的巨大性能提升。
You can see which PHP version your site is using by installing and activating the Version Info plugin.
您可以通过安装并激活“ 版本信息”插件来查看您的网站使用PHP版本。
Upon activation, the plugin will show your PHP version in the footer area of your WordPress admin dashboard.
激活后,该插件将在WordPress管理控制台的页脚区域显示您PHP版本。
![PHP version in WordPress admin dashboard PHP version in WordPress admin dashboard](https://i-blog.csdnimg.cn/blog_migrate/20f4e86387c2fd31c7754f4928e1a432.png)
If your website is using a version lower than PHP 7, then ask your hosting provider to update it for you. If they are unable to do so, then it is time to find a new WordPress hosting company.
如果您的网站使用的版本低于PHP 7,则请您的托管服务提供商为您更新它。 如果他们不能这样做,那么该找一家新的WordPress托管公司了 。
[ 返回页首↑ ]
That’s it! We hope this article helped you learn how to improve wordpress speed and performance.
而已! 我们希望本文能帮助您学习如何提高wordpress的速度和性能。
Go ahead and try out these techniques. Don’t forget to test your website speed before and after implementing these best practices. You’ll be surprised these changes will boost your WordPress performance.
继续尝试这些技术。 在实施这些最佳做法前后,请不要忘记测试您的网站速度。 您会惊讶于这些更改将提高您的WordPress性能。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在Twitter和Facebook上找到我们。
翻译自: https://www.wpbeginner.com/wp-tutorials/18-useful-tricks-to-speed-up-wordpress-boost-performance/
wordpress 加速