Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using custom response headers to help detect site transfers

Tags:

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?

like image 452
simonrjones Avatar asked Aug 18 '09 12:08

simonrjones


People also ask

What is the use of response headers?

A response header is an HTTP header that can be used in an HTTP response and that doesn't relate to the content of the message. Response headers, like Age , Location or Server are used to give a more detailed context of the response.

What information can be seen in a header response?

Response headers hold additional information about the response, like its location or about the server providing it. Representation headers contain information about the body of the resource, like its MIME type, or encoding/compression applied.

Which of the following header ensure that browsers interpret the responses in the way intended?

Use appropriate response headers. To prevent XSS in HTTP responses that aren't intended to contain any HTML or JavaScript, you can use the Content-Type and X-Content-Type-Options headers to ensure that browsers interpret the responses in the way you intend.


1 Answers

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.

like image 155
drench Avatar answered Sep 20 '22 02:09

drench