Depending on your context, wp_die()
will behave differently. This means if you’re inside an AJAX request it will do something else than say a standard http request.
So depending on from where you’re actually calling it, this can make a difference. Say you’re in a normal http request, then it will call _default_wp_die_handler()
which besides adding headers also outputs HTML – which is not what you want.
Just stick with exit
(or die
), this is also recommended in the docs.