Hi srn,
Yes that will work. But as I explained previously there is catch.
The way this works is as follows :
1. Browser sends request for resource /test.html
2. Server sends the response (including the http headers & javascript which has the XMLHTTPRequest code to get headers)
3. Browser executes the java script , thus making a new XMLHTTPRequest for the same resource /test.html
4. Server sends the response for the new XMLHTTPRequest..Print the headers.
So as you could see above, for this to work, browser has to make a new request to the server for the resource.
So as long as there is a guarantee that response headers are the same for a particular request(resource) irrespective of how many time you request it ..then this solution will work.
But also please be careful this solution will have performance overheads to your application if you are going to have this javascript built into all of your application pages.
Cheers,
Ujwol Shrestha