使用自定义响应标头帮助检测站点传输
这更多的是一个最佳实践问题。 在我们公司,我们经常需要将网站从一台服务器转移到另一台服务器。 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
惯例是将“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.