自动推送到CDN部署策略

发布于 2024-08-31 19:52:07 字数 430 浏览 7 评论 0原文

有人对在部署时将内容推送到 CDN 的策略有什么想法吗?

我面临的关键问题是我们有一个可在各种环境下使用的网站:本地开发、开发服务器、登台,然后最终上线。

该网站的肝脏版本需要从域加载资产,该域将指向 CDN:assets.domain.com。

然而,我们将有大量对指向相对文件夹的资源的引用,例如 css 中的 /images/ ,可能在 js 中,以及在 HTML 和 HTML 中。来源。

我们的新站点将使用 capistrano 进行部署,我们可能可以挂钩另一个构建工具(apache ant?)或一些自定义脚本来搜索/替换路径。

我想知道是否有人以前处理过这个问题,以及您采取了哪些解决方案来自动管理 CDN,将内容推送到 CDN 并管理 html 和 HTML 内容。对 CDN 中资产的 css 引用。

谢谢伊曼克

Does anyone have ideas for a strategy to push content to a CDN upon deployment?

The key issue I'm facing is that we have a site that is available in various contexts: local development, development server, staging, then finally live.

The liver version of the site needs to load assets from a domain, which will be pointed to a CDN: assets.domain.com.

However, we will have numerous references to the assets pointing to a relative folder, e.g. /images/ in css, possibly in js, and in HTML & source.

Our new site will use capistrano for deployment and it may be that we can hook in another build tool (apache ant?) or some custom script to search / replace paths.

I am wondering if anyone has had to deal with this issue before and what solutions you put in place to automate managing the CDN in terms of pushing content up to the CDN and managing html & css references to assets in the CDN.

Thanks

Imanc

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风透绣罗衣 2024-09-07 19:52:07

一般来说,CDN 使用基于拉的缓存,而不是基于推的复制。

这是因为将大量(考虑到所有客户)内容推送到任意数量的分布式节点中是一个困难的分布式系统问题,并且预测未来的流量模式以优化该分布甚至更加困难。

虽然有些(例如 Akamai)确实提供了使网络中的内容失效的功能,但它通常被视为“紧急开关”,而不是可以集成到部署过程中的东西。

有些还可能提供“临时服务器”,您可以将内容推送到其中,但它实际上不会进入 CDN;相反,CDN 只会在发生流量时从自己的服务器中提取内容。这可能足以满足您的需求(通常它们提供 FTP、SSH 和其他接口)。

否则,最好的办法是等待您设置的 TTL(例如,Cache-Control: max-age)超时并刷新内容(当内容向后兼容时),或者在以下情况下更改 URL:事实并非如此。

Generally speaking, CDNs use pull-based caching, not push-based replication.

This is because pushing a large (considering all of their customers) amount of content into any significant number of distributed nodes is a difficult distributed systems problem, and anticipating future traffic patterns to optimise that distribution is even more difficult.

While some (e.g., Akamai) do offer the ability to invalidate content in the network, it's usually considered a 'panic switch' rather than something that you can integrate into your deployment process.

Some may also offer 'staging servers' that you can push your content onto, but it really isn't going into the CDN; rather, the CDN will just pull content from their own servers as traffic happens. This might be adequate for what you want (usually they offer FTP, SSH and other interfaces).

Otherwise, your best bet is to wait for the TTLs you've set (e.g., Cache-Control: max-age) to time out and the content to get refreshed, when the content is backwards-compatible, or to change the URLs when it isn't.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文