为什么Google使用base64编码数据作为图像src属性?
在我的一生中,我一直将图像作为文件保存在服务器上:
- 原件、
- 缩略图
- 、带水印的原件
……全部作为文件夹中的文件。
但是今天,我正在查看谷歌图像,并且图像的src是base64编码的哈希值。 Google 通过这种方式提供图像可以获得什么好处?为什么有人会这样做而不是按照传统方式提供图像?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谷歌有点痴迷于延迟;如果您的浏览器必须针对页面上的每个图像向 Web 服务器发出单独的请求,则页面加载的延迟会增加。您可以通过在生成页面时将图像数据直接写入页面来消除这种延迟。我实际上看到很多图像密集的网站,尤其是博客,现在都使用这种技术。
仅仅因为图像包含在页面中并不一定意味着它没有作为文件存储在 Web 服务器上 - 只是生成页面的 Web 服务器进程已经打开并读取图像文件,然后将其数据写入到页。谷歌可能将图像存储在其专有和秘密数据存储中,但您不必这样做。
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.