wordpress用cdn_如何使用CDN加快WordPress

wordpress用cdn

We all love WordPress for being user-friendly, free, and providing us with an easy way to market ourselves to the world. That is one reason why it powers over 29% of all the websites on the internet. Even Scotch.io is powered by WordPress!

我们都喜欢WordPress的用户友好性,免费性,并为我们提供了一种向世界推广自己的简便方法。 这就是它为超过29%的互联网网站提供支持的原因之一。 甚至Scotch.io都由WordPress驱动!

WordPress can be quite a beast when it comes to web performance, however, it definitely is not the fastest platform out there. In fact most developers would probably prefer using a static site generator, which is becoming quite popular.

在网络性能方面,WordPress可以说是一门猛兽,但是,它绝对不是最快的平台。 实际上,大多数开发人员可能更喜欢使用静态站点生成器 ,该站点生成器正变得越来越流行。

However, there are easy and cost effective ways to speed up WordPress without much work. One of them is to implement a CDN (Content Delivery Network). Check out the steps below to get a CDN up and running in only 2 steps!

但是,有许多简便且经济高效的方法可以加快WordPress,而无需进行大量工作。 其中之一是实施CDN(内容交付网络) 。 查看以下步骤,仅需两个步骤即可启动并运行CDN!

什么是CDN? ( What is a CDN? )

Some of you might be wondering what a CDN is? A CDN stands for content delivery network. And to put it simply, it is a global network of edge servers that caches your content on them (like images, javascript, CSS) and then serves it up faster to users physically closer to them.

你们中有些人可能想知道CDN是什么? CDN代表内容交付网络 。 简而言之,这是一个边缘服务器的全球网络,该服务器将您的内容(如图像,javascript,CSS)缓存在其上,然后将其更快地提供给物理上更接近它们的用户。

For example, let's say you have a website hosted with a provider and it sits in a datacenter in Dallas, TX. Every user that visits your site has to query all your website's assets from Dallas, TX, even those across the world. This introduces latency due to the long geographical distances. When you use a CDN it copies assets to a server closer. So let's say someone in the UK visits your site, instead of querying your assets from Dallas, TX, a CDN is now storing a copy of your assets on a server in London. This drastically reduces the latency and ISP hops for that user and makes your WordPress site load super fast!

例如,假设您有一个由提供程序托管的网站,并且该网站位于德克萨斯州达拉斯的数据中心。 每个访问您网站的用户都必须查询德克萨斯州达拉斯市乃至全球的所有网站资产。 由于地理距离长,这会导致延迟。 使用CDN时,它将资产复制到更近的服务器上。 因此,假设某个英国人访问您的网站,而不是从德克萨斯州达拉斯查询您的资产,CDN现在将您资产的副本存储在伦敦的服务器上。 这将大大减少该用户的延迟和ISP跳数, 并使您的WordPress网站加载速度超快!

Simply by adding a CDN I decreased load times by over 55%! - Brian Jackson

只需添加CDN,我的加载时间减少了55%以上! - 布赖恩·杰克逊

CDN的其他好处 ( Other Benefits of a CDN )

Besides increasing the speed of your WordPress site, a CDN also provides a lot of other benefits.

除了提高WordPress网站的速度外,CDN还提供了许多其他好处。

  • ** SEO Benefits:** By increasing the speed of your WordPress site you should see an increase in your Google rankings. Remember that Google uses pagespeed as a ranking factor. Google can also index and crawl your images faster for Google image search.

    ** SEO好处:**通过提高WordPress网站的速度,您应该会看到Google排名的提高。 请记住,Google使用Pagespeed作为排名因素 。 Google还可以更快地索引和抓取图像,以进行Google图像搜索。
  • Scalability: A CDN lets you scale up and down quickly to be ready for sudden traffic spikes.

    可扩展性: CDN使您可以快速扩展和缩小规模,为突发流量高峰做好准备。
  • Security: Mitigating DDoS attacks, secure token, SSL certs are just a few of the extra security measure you can benefit from with a CDN.

    安全性:缓解DDoS攻击,安全令牌,SSL证书只是CDN可以使您受益的其他一些安全措施。
  • ** Increase Conversions:** According to Kissmetrics, a 1 second delay can results in a 7% reduction in conversions.

    **增加转化次数:**根据Kissmetrics的说法 ,延迟1秒可以使转化次数减少7%。
  • Lower Costs: By offloading traffic to a CDN you can save on bandwidth costs with your web host.

    降低成本:通过将流量卸载到CDN,您可以节省Web主机的带宽成本。
  • Extra Caching: A CDN provides additional caching with features such as Origin Shield and cache-control headers.

    额外的缓存: CDN提供额外的缓存,其功能包括Origin Shield和缓存控制标头。
  • Gzip: Compression of your assets happens automatically when they are delivered from a CDN.

    Gzip:从CDN传送资产时,会自动进行资产压缩。

Check out these additional reasons why you should be using a WordPress CDN.

找出这些其他原因,为什么您应该使用WordPress CDN

如何安装CDN ( How to Install a CDN )

Now on to the fun part, how to actually install a CDN. Today, we will show you the quickest and easiest way to deploy a CDN on your WordPress site in just 2 simple steps!

现在开始有趣的部分,如何实际安装CDN。 今天,我们将通过两个简单的步骤向您展示在WordPress站点上部署CDN的最快,最简单的方法!

In our example we are using KeyCDN, which is a content delivery network that features the lowest global prices at $0.04/GB. For most of you that is less than a cup of coffee per month! You can also check out other CDN providers at CDN Comparison. Some features I suggest looking out for are HTTP/2 support as well as Let's Encrypt integrations for free SSL certs.

在我们的示例中,我们使用KeyCDN,这是一个内容交付网络 ,具有全球最低的价格,为$ 0.04 / GB。 对于你们大多数人来说,每月少于一杯咖啡! 您也可以在CDN比较中查看其他CDN提供程序。 我建议寻找的一些功能是对HTTP / 2的支持,以及免费SSL证书的Let's Encrypt集成。

第1步 (Step 1)

First sign in to your KeyCDN dashboard. If you don't have an account yet you can signup here. Click into Zones and then New Zone. Give your zone a name, make sure Pull is selected for the Zone Type and then under the Origin URL put in your full domain name.

首先登录您的KeyCDN仪表板。 如果您还没有帐户,可以在这里注册 。 单击进入区域 ,然后单击新区域 。 为您的区域命名,确保为“区域类型”选择“ 拉” ,然后在完整域名中的“原始URL”下。

Optional: If your site is running on HTTPS, KeyCDN offers free SSL certs with Let's Encrypt. Simply select the Show Advanced Features and enable it with one click.

可选:如果您的站点运行在HTTPS上,则KeyCDN通过Let's Encrypt提供免费的SSL证书。 只需选择“ 显示高级功能”并单击一下即可启用。

第2步 (Step 2)

Now that we have your CDN account setup we just need to set it up on your WordPress site. The easiest way to do this is to install the free WordPress CDN enabler plugin. You can also use the CDN integration in popular caching plugins like WP Rocket, W3 Total Cache, and WP Super Cache. After installing, in your WordPress dashboard, click into Settings and CDN Enabler. You will want to put in your CDN URL, which you can find on your KeyCDN dashboard. Then press Save Changes.

现在我们已经设置了CDN帐户,我们只需要在您的WordPress网站上进行设置即可。 最简单的方法是安装免费的WordPress CDN启动器插件。 您还可以在流行的缓存插件(例如WP Rocket,W3 Total Cache和WP Super Cache)中使用CDN集成。 安装后,在WordPress仪表板中,单击进入设置CDN启动器 。 您将需要输入CDN URL,您可以在KeyCDN仪表板上找到它。 然后按保存更改

And that's it! Your images, Javascript, CSS, should now all be serving from 20+ POPs around the globe.

就是这样! 现在,您的图片,Javascript,CSS都应该在全球20多个POP中投放。

可选-自定义区域网址 ( Optional - Custom Zone URL )

You can take your configuration one step further and setup a custom Zone URL with your own domain name, like cdn.domain.com. This can be beneficial for SEO purposes, branding, and makes it easier to switch CDN providers later if you hardcoded anything (which you shouldn't be doing, but we all know it happens). Follow the steps below to setup a custom Zone URL.

您可以进一步进行配置,并使用自己的域名(如cdn.domain.com)设置自定义区域URL。 这对于SEO的目的,品牌化可能是有益的,并且如果您硬编码了任何内容(您不应该这样做,但是我们都知道会发生这种情况),那么以后更容易切换CDN提供程序。 请按照以下步骤设置自定义区域URL。

第1步 (Step 1)

The first thing you need to do is login to your domain registrar and create a CNAME record. In this example we are using NameCheap, but the process is almost identical with any other provider such as GoDaddy. First click into the Advanced DNS section on your domain and add a new CNAME record. For the host you will input what you want your subdomain to be. The most commonly used one is cdn. Then in the value you will put in your CDN zone URL. You can grab this from the KeyCDN dashboard.

您需要做的第一件事是登录您的域名注册商并创建一个CNAME记录。 在此示例中,我们使用NameCheap,但是该过程与其他任何提供程序(例如GoDaddy)几乎相同。 首先点击您域上的“ 高级DNS”部分,然后添加新的CNAME记录。 对于主机,您将输入您想要的子域。 最常用的是cdn 。 然后,在该值中,您将放入CDN区域URL。 您可以从KeyCDN仪表板中获取它。

第2步 (Step 2)

Once you have the CNAME setup all you need to do is create a zonealias to let the CDN provider know. Simply click into Zonealiases and add a new one. The alias will be the subdomain you chose for the host of your CNAME. In our example we are using cdn.domain.com.

完成CNAME设置后,您所需要做的就是创建一个区域别名以告知CDN提供程序。 只需单击Zonealiases并添加一个新的。 别名将是您为CNAME主机选择的子域。 在我们的示例中,我们使用的是cdn.domain.com。

第三步 (Step 3)

After mapping your zone to your CNAME then simply update the CDN URL in the WordPress CDN Enabler plugin settings.

将区域映射到CNAME之后,只需在WordPress CDN Enabler插件设置中更新CDN URL。

And now all your assets will load from cdn.domain.com. It is recommended to fire up Chrome DevTools, jump into the network tab, and ensure that your assets are indeed loading from the new URL.

现在,您的所有资产都将从cdn.domain.com加载。 建议启动Chrome DevTools,跳到“网络”标签,并确保确实从新URL加载资产。

摘要 ( Summary )

As you can see, setting up a CDN on your WordPress site is not hard at all! In fact, you can get it up and running in a matter of minutes and it won't break the bank. There are a lot of ways to optimize WordPress, but a CDN can give you instant results and users that come to your website from across the country will definitely appreciate it!

如您所见,在WordPress网站上设置CDN一点都不困难! 实际上,您可以在几分钟之内启动并运行它,而不会花钱。 有很多优化WordPress的方法,但是CDN可以为您提供即时结果,来自全国各地访问您网站的用户一定会很高兴!

What are your thoughts on a CDN? Do you use one yet with your WordPress site? If so, we would love to hear your thoughts below.

您对CDN有何看法? 您是否在WordPress网站上使用了一个? 如果是这样,我们很乐意听到您在下面的想法。

翻译自: https://scotch.io/tutorials/how-to-speed-up-wordpress-with-a-cdn

wordpress用cdn

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值