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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With