支持2个文件之间切换的CDN,依赖于User-agent

发布于 2024-11-03 11:08:55 字数 367 浏览 0 评论 0原文

我有一个难题。我希望我的整个域都由 CDN 托管。因此根页面 www.mysite.com/ 应由 CDN 提供服务。这很好。但是,我想有条件地提供不同的页面(或重定向),具体取决于是否检测到用户代理字符串是移动的(例如 http://detectmobilebrowser.com/)。如果可能的话,我希望在服务器端完成此操作。

我知道 Cloudfront 可以根据标头(压缩或不压缩)提供同一文件的 2 个不同版本,但我找不到任何文档说明它或任何其他文件是否支持依赖于用户代理的任何切换方式。有人遇到过这样做的方法吗?

感谢您的大力帮助:D,
Alec

I have a conundrum. I'd like my entire domain to be hosted by CDN. So the root page, www.mysite.com/ should be served by a CDN. This is fine. However I'd like to conditionally serve a different page (or redirect) dependant on whether the user-agent string is detected to be mobile (e.g. like on http://detectmobilebrowser.com/). And I'd like this, if possible, to be done server-side.

I know Cloudfront can serve 2 different versions of the same file dependant on the header (gzipped or not), but I can't find any documentation stating if it or any others support any way of switching dependant on the user agent. Anyone come across a way of doing this?

Thanks for any much appreciated help :D,
Alec

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

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

发布评论

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

评论(2

清眉祭 2024-11-10 11:08:55

当用户尝试访问您想要切换的网页或对象时,您的 CDN 必须能够根据用户代理文本解析结果回复 HTTP 响应 301 Moved Permanently。

Your CDN must be able to reply with a HTTP response 301 Moved Permanently based on the User-Agent text parsing results, when the user tries to access the webpage or object you´d like to switch.

篱下浅笙歌 2024-11-10 11:08:55

内容分发网络 (CDN) 更适合托管图像、脚本、媒体等静态内容文件、文档等而不是整个网站。

其含义是通过从源服务器中删除静态内容以及通过世界各地的服务器网络在本地提供静态内容来减轻负载。

您想要做的典型托管设置是将页面/服务器托管在“正常”提供商处,检测用户代理(客户端或服务器端),然后呈现指向托管在“正常”提供商处的静态资源的链接。基于用户代理的CDN。

对于第二点,正如之前提到的,CDN 被认为托管静态文件,因此不可能对用户代理进行服务器端检测。如果您有一个像我所说的托管环境,在您选择的提供商处有一个页面/服务器,再加上一个 CDN,您将拥有所有选项。

一些提供商(例如 Media Temple)在其正常页面/服务器托管之上提供 CDN 支持。

希望有帮助。

A content delivery network (CDN) is more thought to host your static content like images, scripts, media files, documents etc. instead of your entire website.

The meaning is to lighten the load by removing the static content from your origin server as well as serving the static content more locally through a network of servers around the world.

A typical hosting setup for what you would like to do would be to have a page/server hosted at a "normal" provider, detect the user agent (client side oder server side) and then render the links to the static resources hosted on the CDN based on the user agent.

To your second point, as mentioned before CDNs are thought to host static files so server-side detection of the user agent is not likely. If you have a hosting environment like I stated with a page/server at the provider of your choice plus a CDN you'll have all options.

Some providers (e.g. Media Temple) offers CDN support on top of their normal page/server hosting.

Hope that helps.

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