使用自定义响应标头帮助检测站点传输

发布于 2024-08-02 03:20:26 字数 399 浏览 4 评论 0原文

这更多的是一个最佳实践问题。 在我们公司,我们经常需要将网站从一台服务器转移到另一台服务器。 DNS 需要一段时间才能更新,因此即使实际网站本身没有发生任何变化,能够知道网站何时转移到新服务器通常也是件好事。

我的想法是使用主机服务器名称设置响应标头,以便我可以轻松检查站点何时从新主机提供服务。 在 Apache 中,这可以通过以下方式实现:

Header append Server-Host "servername.studio24.net"

这给了我响应标头:

Server-Host: servername.studio24.net

这是一个好主意吗? 或者我不应该为这种事情使用 HTTP 响应标头?

This is more of a best practice question. At our company we often have the requirement to transfer a website from one server to another. DNS takes a while to update so it's often nice to be able to tell when a site has transferred to the new server, even if there are no changes to the actual website itself.

My thought was to set a response header with the host server name so I could easily check when a site is serving from the new host. In Apache this can be achieved with something like:

Header append Server-Host "servername.studio24.net"

Which gives me the response header:

Server-Host: servername.studio24.net

Is this a good idea? Or should I not be using HTTP response headers for this kind of thing?

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

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

发布评论

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

评论(1

2024-08-09 03:20:26

惯例是将“X-”添加到非标准标头的前面,但是,这很好,而且相当常见,就像 ASP.NET 和 PHP 喜欢使用的“X-Powered-By”标头一样。

The convention is to tack "X-" to the front of nonstandard headers, but yes this is fine, and fairly common, like the "X-Powered-By" headers ASP.NET and PHP like to use.

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