Google 以 Base64 格式发送图像而不是 jpg 有何优势
我注意到 Google 的新页面预览使用 base64 获取图像,而不是普通的 jpg 或 png
这样做的优点是什么?
Base64 编码的图像在传输过程中可以更好地压缩吗?
或者也许可以通过浏览器或缓存代理更好地缓存?
是不是这样他们就可以发出一个 HTTP 请求并一次性接收图像和有关该图像的信息?
还有其他想法吗?
[编辑]
我刚刚有一个想法,也许谷歌可以使用他们的新图像格式
http:// /code.google.com/speed/webp/ 没有浏览器支持?
然而,查看返回的字符串(使用 fiddler 拦截 http 流量),该字符串提到“image/jpeg”。除非有些图片以webp格式返回。
I noticed that Google's new page preview gets it's images using base64 rather than plain e.g. jpgs or png's
What are the advantages of doing this?
Can base64 encoded images be compressed better during transit?
Or perhaps cached better by the browser or caching proxy?
Is it so they can do one HTTP request and receive the image and information about the image in one hit?
Any other ideas?
[EDIT]
I've just had a thought, maybe it's so google can use their new image format
http://code.google.com/speed/webp/ without support from browsers?
However looking at the string returned (using the fiddler to intercept the http traffic), the string mentions "image/jpeg". Unless some images are returned in webp format.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该图像是从服务器接收的数据 URL,作为包含一些元数据的 JSON(-ish) 包。我认为将图像数据和元数据打包到单个请求中在缓存和性能方面是值得的。
The image is a data URL that's received from the server as a JSON(-ish) package with some metadata. I presume that packaging both the image data and the metadata into a single request is worth it in terms of caching and performance.
性能的黄金法则是减少与服务器的连接数量。通过使用数据 URI(以 64 为基数编码的图像数据),可以减少往返次数。此外,如果页面经过 gzip 压缩,则该 Base 64 数据仍然可以从压缩中受益。
请参阅http://developer.yahoo.com/performance/rules.html/
The golden rule for performance is to reduce the number of connections to the server. By using a data URI (image data encoded as base 64), that round trip is reduced. Additionally, if the page is gzipped, then that base 64 data can still benefit from compression.
See http://developer.yahoo.com/performance/rules.html/