'What is the correct content-type for a base64 image?

I have a server-side script which generates an image in response to an AJAX call.

In order to show the image on the page, I am encoding it with Base64.

However, I am not sure what to put in the "content-type" header.

"image/png" seems wrong because the content is actually text which encodes a png, and not actually a png.

"text/plain" seems wrong because it implies plain text and also nginx will try to compress it which is a waste of time as the compression savings will be minimal.

What is the actual correct way to go?

(Also, could I send it as a png and let the client convert it to base64?)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source