问题描述
在网页设计中使用 base64 编码的图像是否安全,它的性能比较如何?优缺点?
Is it safe to use base64 encoded images for web design, How does it compare in performance? Advantages and Disadvantages?
推荐答案
base64 流比二进制流大约重 33%(不考虑 gzip 压缩在 http 上,如果你是认真的表演).
A base64 stream is about 33% heavier than a binary one (not taking into account the gzip compression over http that you have in place if you're serious about performances).
如果你把base64图片直接放在一个页面中,是不会单独缓存的.因此,对于使用此图像而不是使用 URL 作为键可缓存的所有页面来说,这将是沉重的.您可能认为它有助于保持较低的请求数,但实际上在用户缓存中还有图像的正常情况下它是无用的(如果您有很多图像,请使用 css sprite 来减少请求数).
If you put the base64 image directly in a page, it won't be cached separately. So it will be heavy for all pages using this image instead of being cachable with URL as key. You may think that it helps keeping the request number low but in fact it's useless in normal cases where users have yet the images in their cache (if you have many images, prefer css sprites to lower the number of requests).
我认为没有理由使用 base64 图像,除非解决特定的技术问题,例如以 json 格式发送图像,或仅保存一个 html 文件 - 然后检查您是否真的需要使用 base64图片.
I don't think there is a reason to use a base64 image except for when addressing a specific technical issue, like sending an image in json, or saving only one html file - and then check you really need to use the base64 image.
这篇关于将 base64 编码的图像用于 Web 是否安全,优点和缺点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!





大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)