I would like to determine the response header of people who use my website. It is a private website I made for friends but depending on from where you connect I'd like to enable/disable features. A friend of mine chipped in and wrote a snippet which gets the job done, however it is not efficient imo. Moreover, it creates a request which reloads the whole site in the background (which takes quite long).
Here's his code:
var request = new XMLHttpRequest();
request.open("GET", document.location, false);
request.send(null);
var x = request.getResponseHeader("x-custom-one");
var x = request.getResponseHeader("y-custom-second");
Do I understand it right that through settings the second argument for the open method to "document.location" it sends the request to the location where the file is located from which the method is called? That leads to a pretty massive request which loads the whole site in the background.
Anyone got any input for me? Thanks a ton.