Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Google use base64 encoded data as image src attributes?

Tags:

image

base64

All times in my life, I save images on my server as files:

  • the originals
  • the thumbnails
  • the original with watermarks

... all as files in folders.

But today, I'm viewing google images, and the src of images is a base64 encoded hash. What benefit does Google get from serving images in this manner? Why would someone do that instead of just serving images conventionally?

like image 593
Ils Labs Avatar asked Sep 28 '11 10:09

Ils Labs


People also ask

Why is Base64 used for images?

Base64 encoded files are larger than the original. The advantage lies in not having to open another connection and make a HTTP request to the server for the image. This benefit is lost very quickly so there's only an advantage for large numbers of very tiny individual images.

Does Gmail display Base64?

Gmail does not support base64 embedded images. Yet it allows attached images to be shown.

What is Base64 encoded image?

Base64 encoding is a way to encode binary data in ASCII text. It's primarily used to store or transfer images, audio files, and other media online. It is also often used when there are limitations on the characters that can be used in a filename for various reasons.

What is Base64 encoded data?

The base64 is a binary to a text encoding scheme that represents binary data in an ASCII string format. base64 is designed to carry data stored in binary format across the channels. It takes any form of data and transforms it into a long string of plain text.


1 Answers

google is sort of obsessed with latency; latency for the page load goes up if your browser has to go and make a separate request to the web server for every image on the page. you can eliminate this latency by writing the data of the image right into the page when you generate the page. i actually see a lot of image-heavy sites, especially blogs, using this technique nowadays.

just because the image is included in the page doesn't necessarily mean it's not stored as files on the web server -- just that the web server process that generated the page has already opened and read the image file and then wrote it's data into the page. google is probably storing the images in it's proprietary and secret data store, but you don't have to.

like image 176
Igor Serebryany Avatar answered Oct 02 '22 19:10

Igor Serebryany