为什么您的WordPress网站运行缓慢? 加快WP网站速度的简单方法

更新:12年2020月XNUMX日/文章作者:杰里·洛(Jerry Low)

WordPress是迄今为止最受欢迎的内容管理系统(CMS) 为当今世界上超过38%的网站提供支持。 It is valued because of its versatility in allowing website owners to quickly build websites of impressive quality and functionality.它之所以受到重视是因为它具有多功能性,可以使网站所有者快速构建质量和功能令人印象深刻的网站。

However, WordPress does need to be understood in order for it to perform at its best.但是,确实需要了解WordPress,才能使其发挥最佳性能。 If you've been running a WordPress site and feel that performance has been sub-par, you might be able to increase performance by making a few small tweaks.如果您一直在运行WordPress网站,并认为性能已经达到标准以下,则可以通过一些小的调整来提高性能。

speed is important
Your website speed affect conversion rate greatly.您的网站速度会大大影响转换率。 Studies have consistently shown that研究一致表明 快速的页面速度将带来更好的转换率。 一个 转化率下降了20% for every second of delay in mobile page load time.移动网页加载时间的每一秒延迟。 And, according to并且,根据 与谷歌思考,网站快速加载的基准时间是0-1秒。


Caching in general is when applications store data in memory for faster processing or access.通常,缓存是指应用程序将数据存储在内存中以进行更快的处理或访问时。 Similarly, by enabling caching you can pre-load parts of your website for quicker access.同样,通过启用缓存,您可以预加载网站的某些部分以加快访问速度。 There are various modes of caching you can take advantage of but they generally fall into either of two categories;您可以利用多种缓存模式,但是它们通常分为两类。 client-side cache, or server-side cache.客户端缓存或服务器端缓存。

Client-side caching (usually browser caching) helps you define what elements of your site is stored on a visitor's web browser.客户端缓存(通常是浏览器缓存)可帮助您定义网站的哪些元素存储在访问者的Web浏览器上。 It also lets you specify the duration those elements are stored so that if your site is updated, the browser will be able to refresh the cache with updated elements.它还使您可以指定存储这些元素的持续时间,以便在更新站点时,浏览器将能够使用更新的元素刷新缓存。 Browser caching works with static elements such as CSS, JS, and images.浏览器缓存可与CSS,JS和图像等静态元素一起使用。

Server-side caching is any method of caching that is implemented on your web server.服务器端缓存是在Web服务器上实现的任何缓存方法。 These can include这些可以包括 操作码缓存, 页面缓存, 数据库缓存, 和更多。 Each of these methods deal with various elements of WordPress and leveraging on them can help improve our site performance.这些方法中的每一个都处理WordPress的各种元素,并利用它们可以帮助改善我们的网站性能。

For example, WordPress is very highly database-centric.例如,WordPress高度以数据库为中心。 Unfortunately, any processes that work with a database generally require a lot of resources (processing power and memory) to run.不幸的是,任何与数据库一起工作的进程通常都需要大量资源(处理能力和内存)才能运行。 With database caching, what you do is basically save results of previous queries in memory to reduce the time taken to deliver certain results.使用数据库缓存,您要做的基本上是将先前查询的结果保存在内存中,以减少交付某些结果所需的时间。

1解决方案: 安装良好的缓存插件

WordPress缓存插件的一些很好的例子包括 WP火箭 和  迅捷的表现.

2解决方案: 在Web主机上启用OPCache

通过缓存PHP脚本的编译后的操作代码,OPcache使站点可以更快地提供页面内容。 好消息是,大多数共享主机提供商允许其用户从其控制面板安装OPcache扩展。 因此–要使用此选项更快地加载您的网站,只需登录到主机控制面板并启用此功能。

示例:要在以下位置启用OPCache A2 Hosting,登录到cPanel>软件>选择PHP版本>安装PHP扩展。


SSD是传统硬盘的高科技版本,并且速度更快。 However, despite the fall in prices of SSD, they are still more expensive than mechanical hard drives.但是,尽管SSD的价格下降了,但它们仍然比机械硬盘贵。

Because of this, some hosting provider may try to get away with a hybrid setup.因此,某些托管服务提供商可能会尝试摆脱混合设置。 They will run applications off SSDs but use traditional hard drives for storage.他们将在SSD上运行应用程序,但使用传统的硬盘驱动器进行存储。 This is bad news for WordPress users since it is likely the database will reside on the slower, mechanical drives instead of SSD.对于WordPress用户而言,这是个坏消息,因为数据库很可能驻留在速度较慢的机械驱动器上,而不是SSD上。 Make sure you take note of whether your hosting provider is offering a full SSD solution or not.确保记下您的托管服务提供商是否正在提供完整的SSD解决方案。

解: 坚持提供完整SSD托管的托管公司

siteground ssd hosting
示例:所有托管在的网站 SiteGround 在SSD磁盘上运行–非常适合WordPress网站。

尽管是市场上最便宜的WP托管之一, Hostinger 在完整的SSD存储上运行-使它们成为托管WordPress网站的理想选择。 在全固态硬盘上运行的其他知名品牌包括: A2 Hosting, BlueHostSiteGround.


WordPress是基于PHP的,服务器运行的PHP版本也会影响网站性能。 PHP 7 经过测试 速度几乎是PHP 5.6的两倍-性能提高了100%!

AeroSpike的团队跑了 一些测试以比较PHP 5和PHP 7.

Their test launched four processes, each running 100,000 transactions.他们的测试启动了四个流程,每个流程运行3.9.1个事务。 All runs were performed against a one-node cluster running Aerospike Server Community Edition version 7 on CentOS 32 with 5 Intel(R) Xeon(R) CPU E2660-2.20 @ 32GHz processors (with hyperthreading turned on) and XNUMXGB of memory.所有运行均针对具有XNUMX个Intel(R)Xeon(R)CPU EXNUMX-XNUMX @ XNUMXGHz处理器(已启用超线程)和XNUMXGB内存的CentOS XNUMX上运行Aerospike Server Community Edition版本XNUMX的单节点群集执行。 。




Total Execution Time  - PHP7 vs PHP5
PHP 7的总执行时间比PHP 10低约12 – 5%(越低越好)。


Operations per second - PHP 7 vs PHP 5
与PHP 7相比,PHP 9的读写次数约为15 – 5%(越高越好)。

解: 更新您的网站PHP版本

If you're running on an older version of PHP it is likely that you will see pretty good speed improvements simply by choosing a newer version of PHP.如果您运行的是旧版本的PHP,则只需选择新版本的PHP,您可能会看到相当不错的速度改进。 Most web hosting providers will offer multiple versions of PHP which you can select through your web hosting control panel.大多数网络托管提供商会提供多个版本的PHP,您可以通过网络托管控制面板进行选择。

示例–在以下位置选择您的PHP版本 Hostinger 可以通过托管控制面板完成。

4. HTTP / 2

HTTP / 2是一个 “新”互联网协议 该版本于2015年推出。与之前的HTTP 1.1版本不同,它允许同时执行多个数据请求。 这有助于减少网站资产的加载时间。

HTTP / 1.1与HTTP / 2 – HTTP / 2可以通过一个连接发送多个数据请求。 这样可以减少额外的往返时间(RTT),使您的网站加载速度更快(了解更多).

解: 实施HTTP / 2 

Despite this, however, some web hosts still do not offer HTTP/2 or only offer it on more expensive plans.尽管如此,但是某些Web主机仍然不提供HTTP / 2或仅以更昂贵的计划提供它。 There are two ways you can take advantage of HTTP/XNUMX;您可以通过两种方式利用HTTP / XNUMX: look for a host which offers it, or make use of Cloudflare CDN.寻找提供它的主机,或使用Cloudflare CDN。

There are web hosting providers that offer varying levels of HTTP.有一些Web托管提供商提供不同级别的HTTP。 For examples,举些例子, SitegroundGreenGeeks 已经使HTTP / 2在所有计划中可用,但是 A2 Hosting 仅在其Turbo虚拟主机计划或更高版本上提供HTTP / 2。


网站是自动化的,其性能可能会受到其可用资源量的影响。 每个站点都需要具有处理能力和内存来处理Web流量-数量越大,所需的资源就越多。

If your website has a sudden influx of visitors, your hosting plan may not have the resources available to handle all of them at once.如果您的网站突然有大量访客涌入,则您的托管计划可能没有可立即处理所有访客的资源。 This will result in the site either slowing down or becoming unavailable to some requests.这将导致该网站变慢或无法访问某些请求。


例如: Web站点脉冲 提供各种监视工具,可以持续监视您的服务器和网站。

The situation is more likely to occur on shared hosting plans since all the accounts on that server are sharing a fixed amount of resources.由于该服务器上的所有帐户都共享固定数量的资源,因此在共享主机计划中更可能发生这种情况。 To ensure that your site is running smoothly, try and use a site monitoring tool like为确保您的网站运行平稳,请尝试使用网站监控工具,例如 正常运行时间机器人, 网站脉冲新生.

Using those tools will help you judge over a period of time how well your host is performing.使用这些工具将帮助您在一段时间内判断主机的性能如何。 If your site keeps slowing down or the server is always down, it might be time to consider shifting to a better plan or a different web host altogether.如果您的网站持续变慢或服务器始终处于关闭状态,那么可能是时候考虑改用更好的计划或完全使用其他Web主机了。

解: 如有必要,升级到VPS或更高级别的托管

示例:基于我们的跟踪 主机分数,SiteGround VPS托管响应时间(测试网站托管在欧洲)比SiteGround共享托管大约快15%。

VPS托管计划比共享托管计划贵,但可以更轻松地处理高流量。 This is because这是因为 VPS托管计划 通常具有可扩展性,这意味着如果您觉得自己的网站需要更多资源,则可以动态增加资源量。


While big, sharp images or exciting videos can be great eye-candy, do remember that these multimedia files often are large in size.虽然大而清晰的图像或令人兴奋的视频可以吸引人,但请记住,这些多媒体文件通常很大。 As a rule of thumb, the bigger a file is the longer it takes to load.根据经验,文件越大,加载所需的时间越长。



Images can be scaled down somewhat and using the right format can also help reduce size.图像可以按比例缩小,使用正确的格式也可以帮助减小尺寸。 For example, a BMP file will usually be larger than a GIF or JPG file.例如,BMP文件通常比GIF或JPG文件大。 To optimize images, you can choose to do so manually or by using a plugin.要优化图像,可以选择手动或使用插件来进行优化。 Some WordPress plugins that can do the trick include可以解决问题的一些WordPress插件包括 EWWW短像素.

If you decide not to use a plugin there are also online tools that you can use to manually optimize images.如果您决定不使用插件,也可以使用在线工具手动优化图像。 Some of these are其中一些是 OptimizillaEzGIF.


Earlier I mentioned about how WordPress is very database-centric and how SSD storage can help speed up queries.之前我提到过WordPress如何以数据库为中心,以及SSD存储如何帮助加快查询速度。 However, the condition of the database also plays a part in the performance of your site.但是,数据库的状况也会影响网站的性能。


It can be very difficult to control every single element that goes into your database, so from time to time, you need to perform some housekeeping.控制进入数据库的每个元素可能非常困难,因此,您有时需要执行一些内务处理。 This will help keep your database organized and able to work at full speed.这将有助于保持您的数据库井井有条并能够全速工作。

There are also plugins you can use for this.还有一些插件可用于此目的。 Some good examples are一些很好的例子是 WP DB管理器WP扫描.



This process which involves the translation of domain names into IP addresses takes time.该过程涉及将域名转换为IP地址需要花费时间。 Different DNS providers perform differently and using a good DNS provider can speed up your site loading speed as well.不同的DNS提供程序的性能有所不同,并且使用良好的DNS提供程序也可以加快您的网站加载速度。


要检查您的DNS速度,请使用 Pingdom的工具 and then click on the first instance of your domain name in the results chart.然后在结果图表中单击您的域名的第一个实例。 This will expand a box showing you the components of your TTFB.这将展开一个框,为您显示TTFB的组件。 In that box, look for a line that says “DNS”.在该框中,找到显示“ DNS”的行。


将其与各种提供商的汇总DNS速度进行比较 DNS Perf上的图表 and consider if your DNS speed is where it should be.考虑一下您的DNS速度是否应达到的水平。 If not, opting for a different DNS provider can be beneficial to your site loading speed.否则,选择其他DNS提供商可能会对您的网站加载速度有所帮助。

CloudFlare的 是周围最受欢迎的DNS提供商之一,您可以免费获得一个帐户。


One of the things that people love about WordPress is how easily it is to boost functionality simply by using a plugin.人们喜欢WordPress的一件事是,只需使用插件即可轻松增强功能。 Because it is open source, WordPress has a由于是开源的,WordPress具有 庞大的开发者社区 这是一个很好的选择,但导致插件的质量差异很大。

Plugins are also extensions to basic WordPress code, meaning that the more you use, the bulkier your WordPress instance will be.插件还是基本WordPress代码的扩展,这意味着您使用的次数越多,您的WordPress实例就越庞大。 This in turn adds to the overhead of your site and may affect performance to varying degrees.反过来,这会增加网站的开销,并可能在不同程度上影响性能。


Where possible make sure that you only run the plugins that you really need and try to trim unnecessary fluff.在可能的情况下,请确保只运行真正需要的插件,并尝试修剪不必要的绒毛。 Also, remember to remove any plugins which aren't in use!另外,请记住删除所有未使用的插件! There are many plugins today which try to accomplish many different things, so where possible try to ensure that functionality isn't duplicated by your plugins.当今有许多插件试图完成许多不同的事情,因此,在可能的情况下,请尝试确保插件不重复其功能。


过去,黑客曾经接管网站并造成混乱。 当今的网络犯罪分子更加复杂,将尽力避免您发现它们的存在。 他们的目的是利用您帐户上的资源来充实自己-例如,通过使用它来挖掘加密货币。

This takes away resources from your site and can have great impact on performance.这会占用您网站的资源,并且可能会对性能产生重大影响。 Because they're flying under the radar, you need to actively scan your site regularly to ensure that it hasn't been hijacked silently.由于它们在雷达下飞行,因此您需要定期主动扫描您的站点,以确保它未被默默地劫持。

从知名的安全解决方案提供商那里购买安全工具,例如 Sucuri and make sure you only install plugins from trusted sources.并确保您仅安装来自受信任来源的插件。 To check if your plugins are legit, use a tool like要检查您的插件是否合法,请使用类似 插件安全检查器 扫描问题。

为避免并发症,请尝试 检查插件的声誉 甚至没有安装它。


As you can see by now, running an efficient WordPress site can be practically a full time job.如您现在所见,运行一个高效的WordPress网站实际上是一项全职工作。 However, if you list down and regularly follow best practices, you'll be able to reduce the chances of a low-performing WordPress site like it was second nature.但是,如果您列出并定期遵循最佳做法,则可以减少表现不佳的WordPress网站的机会,因为这是第二自然。 Remember to stay focused on performance in everything you do and carefully consider anything you want to add on to your site.记住要始终专注于所做工作的性能,并仔细考虑要添加到站点的任何内容。 Many new WordPress site owners tend to go overboard and throw in everything but the kitchen sink.许多新的WordPress网站所有者倾向于过度投入并且扔掉除厨房水槽之外的所有东西。


关于Jerry Low

WebHostingSecretRevealed.net(WHSR)的创始人 - 100,000用户信任和使用的托管评论。 超过15在网络托管,联盟营销和SEO方面的多年经验。 ProBlogger.net,Business.com,SocialMediaToday.com等的贡献者。