azure - 使用 azure CDN 缓存 picsum 图像

标签 azure caching cdn azure-cdn

我创建了一个临时应用程序来测试 azure 缓存功能以研究 az204。
它是应用程序服务中的一个简单的节点应用程序,使用 lorem picsum 渲染大图像。 .

<img src="https://picsum.photos/2000" style="width: 100%;">

我创建了一个Standard Azure CDN Profile并添加了端点。 然后设置要覆盖的全局规则,始终缓存过期时间为 30 分钟。

预期结果:
从这一刻起,我期望我的应用程序缓存图像,这意味着当我重新加载从 CDN 的 url 访问的页面时,我应该获得与之前相同的图像至少 30 分钟。

实际结果:
但实际结果是,当我加载页面时,它总是加载不同的图像,就像没有 CDN 时一样。

我还尝试为图像类型 jpeg 覆盖 30 分钟创建新规则,但没有成功。

如何使用 Frontdoor Azure 标准缓存 CDN 从 lorem picsum 返回缓存图像?

最佳答案

我尝试在我的环境中重现相同的情况,如果您尝试访问 Azure CDN 缓存规则来缓存过期时间,则条件会通过存储 blob 文件。

我已经创建了前门 CDN 配置文件端点并添加了缓存行为覆盖,如下所示:

enter image description here

此缓存规则适用于您的存储容器文件,如下所示:

enter image description here

在存储容器 -> 文件中。我们可以通过 url 访问此文件,如果缺少缓存行为,则覆盖和设置。

https://lorem.azureedge.net/container1/lorem pic 1.jpg

将 TTL 设置为 86400 或 1 天缓存控制Cachecontrol="public,max-age=86400"

Changing the cache duration while accessing the url lorem picsum is not possible

当您检查前门设计器时,这些是可以在不同边缘实现的不同缓存行为。

enter image description here

引用文献:

Azure Storage Azure Front Door Azure CDN

Integrate Caching And CDNs Within Solutions 作者:蒂亚戈·维瓦斯 (Thiago Vivas)

关于azure - 使用 azure CDN 缓存 picsum 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75278710/

相关文章:

c# - 如何创建与 Microsoft.Azure.Management.Compute 一起使用的 ServiceClientCredential

caching - 超出 Neo4j GC 开销限制

.net - Azure CDN 缓存,图像未立即更新?

nginx - 如何禁用 Nginx 索引目录以仅允许 MaxCDN/NetDNA CDN?

python - 添加 python 模块 google-cloud-storage 导致正在运行的 Azure Function App 崩溃

azure - 预定的网络作业与时间表混淆

azure - 我尝试使用 ARM/bicep 和 HTTP 触发器来部署函数应用程序

java - 在 Apache Felix 中禁用缓存

c# - 使用集合时如何实现线程安全的缓存机制?

azure - Windows azure 带宽和 CDN 之间的关系