Cloudflare Cache Reserve Walkthrough and Demo

Cloudflare
24 Mar 202309:49

Summary

TLDR此视频分享了如何使用Cloudflare的缓存预留功能来提高网站内容的缓存命中率。它首先介绍了Cloudflare CDN的基本工作原理,然后重点讨论了缓存预留的功能和流程。演示了如何在Cloudflare仪表盘中启用该功能,并通过缓存数据到Cloudflare的持久化存储桶来进一步减少服务器负载并降低成本。最后,视频还展示了如何使用Cloudflare的日志和分析功能,更好地了解缓存命中情况和缓存预留的使用情况。

Takeaways

  • 💻 Cloudflare CDN 可自动导入当前 DNS 提供商记录,并为用户提供 Cloudflare DNS 服务器使用。
  • 🏃 Cloudflare CDN 提供两种加入方式:更改权威 DNS 或部分 CNAME 设置。
  • 🗃️ Cloudflare 会根据文件扩展名缓存可缓存内容,当缓存内容过期或手动清除时,会从源服务器重新获取。
  • 🌳 缓存分为多层,仅顶层数据中心能从源服务器获取内容。智能分层缓存拓扑可以改善带宽效率和减少源服务器压力。
  • 🔄 当发生缓存未命中时,Cloudflare 首先检查持久存储桶中的内容,再从源服务器获取,进一步提升缓存率。
  • ⏰ 对于过期或被清除的内容,Cloudflare 会先检查持久存储桶,若内容仍存在则从存储桶获取,降低从源服务器获取频率。
  • 🚀 演示中网站部署在第三方云提供商,使用自动流量模拟访问。Cloudflare 控制面板可展示缓存状态和持久存储使用情况。
  • 📝 演示中缓存命中率从80%提升至92%,接近100%的优化目标。Cloudflare 提供页面规则微调缓存行为。
  • ⌛ 用户可自行设置资源缓存时间,覆盖源服务器设置的 TTL。日志推送功能支持记录来自持久存储的请求数据。

Q & A

  • 什么是Cloudflare CDN?

    -Cloudflare CDN(内容分发网络)是一个全球分布的网络基础设施,可以加快网站内容的传输,并提高整体性能。它通过缓存网站内容并将其存储在靠近用户的数据中心,从而减少了从源服务器检索内容的需求,从而降低了延迟并提高了网站的可用性。

  • 如何开始使用Cloudflare CDN?

    -要开始使用Cloudflare CDN,您只需在仪表板上单击"添加站点",输入您的域名即可。Cloudflare可以自动从您现有的DNS提供商导入DNS记录。然后,您将获得Cloudflare的名称服务器,可用于更改授权DNS,使用Cloudflare的DNS和CDN。如果您不想更改主DNS,也可以通过部分CNAME设置使用Cloudflare CDN。

  • 请简要解释一下Cloudflare CDN的基本流量流?

    -当用户发出HTTP请求时,最接近用户的Cloudflare数据中心将处理该请求。如果请求的URL与可缓存文件扩展名列表匹配,则Cloudflare将从缓存中提供该资源(如果存在)。否则,Cloudflare会尝试从多个网络位置的缓存中获取内容并提供服务。如果内容仍然存在于Cloudflare的缓存中,则会尝试从源重新验证内容。如果资源不在缓存中,Cloudflare会从源请求资源以填充缓存,然后将响应发送给发起请求的客户端。

  • Cloudflare Cash Reserve是什么?

    -Cloudflare Cash Reserve是一种功能,可以进一步提高缓存命中率,将所有可缓存文件自动存储到Cloudflare的持久对象存储桶中。当发生缓存未命中时,Cloudflare将首先在这些存储桶中查找内容,而不是直接从源检索。Cash Reserve充当了终极高级层,有助于减少从源获取内容的需求。

  • 使用Cash Reserve后,流量流会有什么变化?

    -使用Cash Reserve后,当客户端向最近的Cloudflare数据中心发出请求时,如果内容在该数据中心和高级层数据中心都没有被缓存,高级层数据中心将先在Cash Reserve中查找内容,而不是立即从源请求。如果内容存在于Cash Reserve,则从那里检索。否则,Cash Reserve将从源请求内容。响应将被缓存在Cash Reserve、高级层和低级层数据中心。下次请求相同内容时,如果在低级层和高级层的缓存都失效,Cloudflare会先在Cash Reserve中查找,如果存在,则从那里提供服务并缓存在其他层。

  • Cash Reserve使用Cloudflare网络的哪些部分?

    -Cash Reserve充当了Cloudflare网络中"终极高级层"。当在低级层和高级层数据中心的缓存都失效时,Cloudflare会先查看Cash Reserve,而不是立即从源请求内容。这有助于最小化从源获取内容的需求,从而减少不必要的出口费用。

  • 如何监控Cash Reserve的使用情况?

    -在Cloudflare仪表板中,您可以查看Cash Reserve中当前存储的数据量、一段时间内使用的总存储量,以及总体的Cash Reserve读写操作数。您还可以查看"总体缓存状态",包括由Cloudflare服务的内容和由源服务的内容。使用分析和日志功能,您可以设置日志推送并包括"Cash Reserve 已使用"字段,以获得有关从Cash Reserve服务的请求和相应内容的更多可见性。

  • 如何在Cloudflare中管理缓存行为?

    -在Cloudflare仪表板中,您可以"清除缓存"以手动清除缓存(包括Cash Reserve)。您还可以使用"页面规则"来创建更细粒度的缓存行为。在"缓存规则"下,您可以为特定主机名创建规则,以覆盖来自缓存控制标头的TTL设置。这可以在边缘完成,并且为所有资产一次性设置TTL非常方便。

  • 使用Cash Reserve有什么好处?

    -使用Cash Reserve可以进一步提高缓存命中率,因为当在Cloudflare网络的其他层发生缓存未命中时,内容将首先从Cash Reserve检索。通过最小化从源请求内容的需求,它有助于减少延迟,减少带宽使用,降低源服务器负载,使网站的运营成本更低。从而提供更好的整体性能。

  • 什么时候会发生缓存未命中?

    -有两种情况会导致缓存未命中:1)有意的 - 缓存TTL过期或内容被手动清除;2)无意的 - 由于Cloudflare的LRU(最近最少使用)算法来优化存储空间,不常访问的内容可能会被清除。在这两种情况下,Cash Reserve都可以作为最后一道防线,提高缓存命中率。

Outlines

00:00

📚 CloudFlare CDN入门和流量流程

段落1介绍了CloudFlare CDN的基础知识,如何从仪表板开始使用,以及通过CloudFlare CDN的流量流程。当用户请求某个资源时,最近的数据中心会处理该请求。如果资源可缓存,则从缓存中提供。否则,从源服务器获取资源并缓存。CloudFlare使用分层缓存拓扑结构,包括上层和下层数据中心,以控制带宽和连接数。智能分层缓存拓扑是所有计划的默认选项。在流量流中,客户端请求到达最近的下层数据中心。如果在下层未缓存,则会检查上层数据中心。如果上层也未缓存,它会从源服务器请求内容并缓存。接下来当另一客户端请求同一内容时,如果上层已缓存,就不需要再从源服务器获取。另外介绍了缓存过期和云朗缓存清除的原因。

05:01

💾 CloudFlare Cash Reserve详解和演示

段落2介绍了CloudFlare Cash Reserve功能以进一步提高缓存命中率。Cash Reserve会自动将所有可缓存文件存储在CloudFlare持久对象存储桶中。在流量流中,当上层数据中心未缓存内容时,会先检查Cash Reserve而不是立即从源请求。如果Cash Reserve有缓存,则返回并缓存在上层和下层数据中心。这一流程大大减少了不必要地从源服务器请求内容。演示部分展示了如何在CloudFlare仪表板中启用Cash Reserve,查看存储使用情况和读写操作数。用于了解在启用Cash Reserve之前和之后的缓存命中率差异。还演示了如何通过缓存规则覆写源服务器的缓存控制头,以及如何记录Cash Reserve使用的日志信息。

Mindmap

Keywords

💡Cloudflare CDN

Cloudflare内容分发网络(CDN)是一种服务,旨在通过全球分布的服务器网络加速网站和网页内容的加载速度。在视频中,讲解者介绍了如何通过Cloudflare CDN轻松开始和上线,强调了其在提高网站性能和减少原始服务器负载方面的重要性。例如,通过自动导入DNS记录和提供Cloudflare的名称服务器,用户可以快速集成Cloudflare CDN到他们的网站。

💡DNS

域名系统(DNS)是互联网的电话簿,将人类可读的网站名称(如example.com)转换为机器可读的IP地址。视频中提到,Cloudflare可以自动从用户现有的DNS提供者那里导入DNS记录,并允许用户使用Cloudflare的DNS作为权威DNS,这是将网站接入Cloudflare CDN的一部分。

💡缓存

缓存是存储临时数据以便快速访问的技术。在视频中,缓存是Cloudflare CDN提高网站性能的关键方法之一。通过缓存可缓存的文件扩展名列表上匹配的HTTP请求,Cloudflare可以从缓存中提供资源,减少对原始服务器的请求。这降低了延迟,节省了带宽,并减轻了服务器的负担。

💡Cache Reserve

Cache Reserve是Cloudflare提供的一个功能,允许将所有可缓存的文件自动存储到Cloudflare的持久对象存储桶中。视频中解释了Cache Reserve如何作为最终的上层缓存层,在发生缓存未命中时,Cloudflare会首先检查这些存储桶,而不是直接从原点请求。这进一步提高了缓存命中率,减少了不必要的出口费用。

💡Tiered Cache

分层缓存是一种优化缓存机制,通过将Cloudflare的全球数据中心网络划分为上层和下层来控制带宽和连接数。视频中提到,只有上层被允许从原点请求内容,并负责将信息分发给下层。这种智能分层缓存拓扑结构默认开启,并为所有计划免费提供。

💡缓存命中率

缓存命中率是衡量缓存系统效率的指标,即从缓存中成功提供请求内容的比例。视频中,通过引入Cache Reserve,讲解者展示了缓存命中率从80%提高到90%以上,显示了Cache Reserve对于提高缓存命中率和优化网站性能的重要性。

💡缓存控制

缓存控制是HTTP头部用来定义页面或其他资源的缓存策略的一部分。在视频中,讲解者讨论了如何通过设置缓存控制时间(TTL)来指示内容何时过时并需要重新验证。此外,用户可以手动清除内容,或者依赖Cloudflare使用最少最近使用(LRU)算法自动优化存储空间。

💡HTTP请求

HTTP请求是客户端(浏览器)和服务器之间通信的一种方式,用于请求网页内容。视频中详细讨论了HTTP请求如何被Cloudflare CDN处理,包括如何根据可缓存的文件扩展名列表匹配和服务请求,以及如何从缓存或原点获取内容。

💡原点

原点是指托管网站内容的服务器。在Cloudflare CDN的上下文中,当缓存中不存在请求的内容时,Cloudflare会向原点发出请求以填充缓存并将响应发送给客户端。视频中提到了原点的重要性,特别是在讨论如何通过减少对原点的请求来优化性能和成本效益。

💡分析和日志

分析和日志提供了关于网站性能和流量模式的重要信息。视频中,讲解者展示了如何使用Cloudflare的分析和日志功能来监控缓存状态、缓存命中率和其他关键指标,以及如何配置日志推送来跟踪和分析从Cache Reserve服务的请求。这些工具对于优化网站性能和用户体验至关重要。

Highlights

云服务商Cloudflare的CDN简介,包括如何开始使用和上手 Cloudflare CDN。

Cloudflare CDN的基本流量流程。

Cloudflare的层级缓存(Tiered Cache)及其智能分层拓扑结构。

何时会发生缓存未命中的情况。

Cloudflare Cash Reserve介绍及其作用。

启用Cash Reserve后的流量流程。

示例网站部署和启用Cash Reserve。

查看Cash Reserve使用情况和数据。

缓存命中率提升情况。

查看缓存详情,包括热门文件类型等。

Purge缓存。

Page规则设置缓存行为。

缓存规则和过期时间覆盖。

外部日志及Cash Reserve使用情况记录。

总结及补充资料链接。

Transcripts

play00:00

hello my name is humir Ahmed and in this

play00:02

video I'm going to walk through Cloud

play00:03

for cash reserve and follow up with demo

play00:06

I will very briefly discuss some Basics

play00:08

from cloud for CDN before getting right

play00:10

into Cash Reserve to provide a better

play00:12

grasp of how everything fits together

play00:14

however I'll keep this very minimal so I

play00:16

can focus on cash Reserve for more

play00:19

thorough understanding of cloud

play00:20

vercidian in general and how it works

play00:22

please see the cloud for CDN reference

play00:24

architecture in the prior video I did on

play00:26

cloudflare CDN walkthrough with that

play00:29

let's get going

play00:31

first let's talk about how easily you

play00:33

can get started and onboarded onto

play00:34

cloudflare CDN

play00:36

from the dashboard simply click add site

play00:38

and enter your domain cloud4 can

play00:41

automatically import your DNS records

play00:43

from your existing DNS provider and

play00:46

finally you're given Cloud for name

play00:47

servers you can use to change your

play00:49

authoritative DNS so here you're using

play00:51

cloudford's DNS Azure authoritative DNS

play00:54

and also onboarded onto cloudflare CDN

play00:58

now if you don't want to change your

play01:00

primary or authoritative DNS you can

play01:02

still use cloudflare CDN by simply doing

play01:05

a partial cname setup so lots of

play01:07

flexibility there

play01:10

so if we look at the very basics of the

play01:12

traffic flow now first HTTP request is

play01:15

made closest data center to user handles

play01:19

the request users HTTP request URL is

play01:22

matched against the list of cachable

play01:24

file extensions if the request matches

play01:27

an extension on the list Cloud first

play01:28

serves the resource from Cache if

play01:30

present

play01:31

second content is fetched from Cache or

play01:34

origin cloudflare examines its caches in

play01:37

multiple Network locations for content

play01:39

and serves it if present if the content

play01:42

is still in Quad verse cache cloudfare

play01:44

attempts to revalidate the content with

play01:45

the origin before serving the response

play01:47

to the client if the resource is not

play01:50

present in the cache Cloud Fair requests

play01:52

the resource from the origin to fill the

play01:53

cache and the response is then sent to

play01:55

the client who initiated the request

play01:59

if cachable content is cached on the

play02:01

response so cloudflare's cash logic

play02:04

examines the HTTP response received from

play02:07

the origin the response is either deemed

play02:09

cachable and written to disk for use

play02:10

with the next request for the same

play02:12

resource or the request is deemed

play02:14

uncashable

play02:17

now let's take a look at the traffic

play02:19

flow with Cloud Fair tiered cache with

play02:21

smart tiered cache topology enabled as a

play02:24

reminder tiered cash divides

play02:26

cloudflare's network of global data

play02:28

centers into a hierarchy of upper tiers

play02:30

and lower tiers and in order to control

play02:32

bandwidth number of connections between

play02:34

an origin and cloudflare only upper

play02:37

tiers are permitted to request content

play02:39

from an origin and are responsible for

play02:41

Distributing information to the lower

play02:43

tiers smart tiered cash topology is the

play02:46

default topology and available for free

play02:48

for all plans this is also recommended

play02:50

for most deployments instructing

play02:52

cloudflare to find the single best upper

play02:54

tiers for your Origins

play02:56

benefits here include improved bandwidth

play02:59

efficiency reduced origin load and

play03:01

making websites more cost effective to

play03:03

operate

play03:04

so when client one sends a request to

play03:06

the closest data center data center one

play03:08

here

play03:09

if the content is not cached the upper

play03:11

tier data center label data center 3

play03:13

here is checked if the content is not

play03:16

cached at the upper tier the upper tier

play03:17

requests the content from the origin

play03:19

once their sponsors returned from the

play03:22

origin the upper tier caches it and

play03:24

returns a response to the lower tier

play03:25

which also caches it and returns a

play03:28

response to the client

play03:30

now let's say client 2 makes the same

play03:32

request for the same content to its

play03:34

closest data center data center too

play03:37

if the content is not cached to Data

play03:39

Center too similar to Prior the upper

play03:41

tier data center is checked however in

play03:44

this case content was requested prior

play03:46

via client 1 and the upper tier data

play03:48

center has the content cached and

play03:50

Returns the cache content to the lower

play03:52

tier data center data center 2 which in

play03:55

turn caches the content and responds

play03:57

back to the client decreasing latency

play03:59

saving bandwidth and load on the server

play04:01

and providing better overall performance

play04:05

so now that we have a better

play04:07

understanding of cloud for CDN when does

play04:09

a cache Miss occur well we have two

play04:11

scenarios first intentional cash TTL

play04:15

expired or content purged customers set

play04:18

cache control time to signify when the

play04:20

content is out of date and needs to be

play04:22

revalidated once expired content needs

play04:25

to be revalidated and may need to be

play04:27

pulled from the origin if updated

play04:28

version exists customers can Purge

play04:31

content manually at any time

play04:33

second unintentional cloudflare Purge

play04:36

content due to lru or least recently

play04:38

used algorithm to optimize storage less

play04:41

frequently accessed content may be

play04:43

purged based on lru or how long the

play04:45

network wants content to remain cached

play04:48

now this is where Cloud for cash Reserve

play04:51

can be useful to further increase cash

play04:53

hit ratio by automatically storing all

play04:56

cachable files into cloudflare's

play04:58

persistent object storage buckets

play05:01

basically cash Reserve acts like an

play05:03

ultimate upper tier and when there's a

play05:05

cash Miss cloudflare will first check

play05:07

these storage buckets before going to

play05:09

the origin you can see here I've enabled

play05:12

it and I'll walk through this more in

play05:14

the demo

play05:15

so let's look at the traffic flow now

play05:18

again when the client sends a request to

play05:20

the lower tier data center if the

play05:22

content is not cached the upper tier

play05:24

data center is checked this time however

play05:26

if the content is not cached at the

play05:28

upper tier the upper tier checks cash

play05:30

Reserve instead of requesting straight

play05:32

from the origin

play05:33

if the content is not present in cash

play05:35

Reserve cash Reserve will request it

play05:37

from the origin once response is

play05:40

returned from the origin cash Reserve

play05:41

caches the content while replying to the

play05:44

upper tier which also caches it and

play05:46

Returns the response to the lower tier

play05:48

which also caches it and responds to the

play05:50

client now next time the same content is

play05:53

requested if there is a cache Miss at

play05:55

the lower tier data center the upper

play05:57

tier data center is checked now if

play05:59

there's say cache missed at the upper

play06:01

tier data center let's say expired TTL

play06:03

or content has been evicted cash Reserve

play06:06

will be checked and if content exists at

play06:08

Cash reserve it will be returned and

play06:10

cached at the upper tier before being

play06:12

returned and cashed at the lower tier

play06:14

and returned to the client so you can

play06:17

see here how cash Reserve acts as the

play06:19

ultimate upper tier and minimizes the

play06:21

need to pull from the origin decreasing

play06:23

unnecessary egress fees

play06:25

with that let's jump into the demo for

play06:28

demonstration purposes I deployed a site

play06:30

here that's basically a large image and

play06:32

video gallery for uploading and

play06:34

downloading content

play06:36

now again for demonstration purposes the

play06:39

website is actually hosted on a

play06:41

third-party Cloud I also have automated

play06:44

traffic running to simulate visitors

play06:46

accessing the site

play06:48

so now I'm going to go over and head

play06:49

over to my cloudflare dashboard and here

play06:52

you can see I have cash Reserve enabled

play06:55

and it shows the current amount of data

play06:57

stored in cash Reserve as well as the

play06:59

total aggregate storage used over the

play07:02

specific time period and you also have a

play07:04

view of total cash Reserve read and

play07:06

write operations once enabled cash

play07:09

Reserve will start caching files with a

play07:11

retention period of 30 days which will

play07:13

be reset on any hits

play07:15

customers can also pause using cash

play07:17

Reserve meaning cloudflare's network

play07:19

will no longer use cash Reserve to serve

play07:21

data

play07:22

here under overview you can see the

play07:25

overall cash status including content

play07:27

served by cloudflare and content served

play07:30

by the origin

play07:31

you can see the vast majority of

play07:33

requests are served by cloudflare and if

play07:36

you scroll down here and hover over the

play07:38

cast status you can see a

play07:41

92.96 cash hit ratio really good now

play07:45

since I just enabled cash reserve a few

play07:47

days ago if I go up here instead of 24

play07:50

hours I select previous 30 days

play07:54

we could see the cash hit ratio was

play07:56

lower at around 80 percent so cash

play07:59

Reserve really helped get into that 90

play08:01

plus ratio getting us closer and closer

play08:04

to that hundred percent

play08:06

and scrolling down here you can see more

play08:08

overall caching details in general like

play08:10

the most popular content types and what

play08:13

specific content is the most popular

play08:15

here on the left you can also Purge the

play08:17

cache which will also Purge content and

play08:19

cash reserves you can also create page

play08:21

rules to get more granular on any

play08:23

specific caching behavior let's go into

play08:26

this and take a look in more detail you

play08:28

can see I created a page rule matching

play08:31

on all requests that contain this

play08:33

specific domain name

play08:34

and I set the cache level to Cache

play08:37

everything that's cachable but also can

play08:39

select different cash level including

play08:41

bypassing cache if desired

play08:43

so now I'm gonna head over to caching

play08:45

and look at Cash rules

play08:48

so under cash rules I can also create a

play08:51

rule as I did here to override ttls from

play08:54

Cache control headers

play08:56

this is done right at the edge and you

play08:58

can see here if I click into it

play09:00

all requests to this hostname

play09:03

I've configured as content eligible for

play09:06

caching and overridden the origin TTL

play09:08

setting it to 12 hours with cloudflare

play09:11

httl it makes it very convenient to set

play09:14

TTL in one place for all assets

play09:17

now I'm going to head over to analytics

play09:19

and logs there

play09:21

and I'll go under logs you can see I've

play09:24

set up a log push I'm just going to

play09:25

click edit here

play09:27

last thing I want to show here is you

play09:29

can also log data to external logs and

play09:31

include the cash Reserve used field to

play09:34

get more visibility into requests and

play09:36

respective content being served from

play09:38

cash Reserve I hope you found this

play09:40

cloudflare cash Reserve walkthrough in

play09:42

demo informational and useful for

play09:44

additional details make sure to check

play09:45

out the cloudflare cash Reserve product

play09:47

page

Rate This

5.0 / 5 (0 votes)

هل تحتاج إلى تلخيص باللغة الإنجليزية؟