There is no safe way to detect Ajax requests.
Ajax request have the same pattern as GET/POST normal pageviews.
HTTP Headers starting with X_ are custom fields which are not even implemented in every Ajax library.
You should not rely on this information and therefore implement a completely different way of what you want to achieve.
I do care about older browsers and older PHP installations as I want
to make my code work in as many situations as possible.
If this is your goal, forget about the header.
The best and shortest answer is right next to mine from Quentin:
It would be cleaner to forget about having the server care about the
difference between "Ajax" and "Not Ajax" and instead of care about
(for instance) "Want JSON" and "Want HTML".
On the internet, you can't ask "Where are you from and which ride did you take" and get a reliable answer at all. The interwebs are not designed to fit this kind of question.