基地64 CS code VS加载图像文件 [英] Base 64 encode vs loading an image file

查看:165
本文介绍了基地64 CS code VS加载图像文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的东西在PHP,我不得不从SQL数据库,他们将连接用base64 codeD让我的图片的工作。显示这些图像的速度是至关重要的,所以我试图找出是否会更快打开数据库中的数据到一个图像文件,然后在浏览器中加载它,或者只是呼应了原始的base64数据及用途:

So I am working on something in php where I have to get my images from a sql database where they will be encoded in base64. The speed of displaying these images is critical so I am trying to figure out if it would be faster turn the database data into an image file and then load it in the browser, or just echo the raw base64 data and use:

<img src="data:image/jpeg;base64,/9j/4AAQ..." />

这在Firefox和其他浏览器的Gecko支持。

Which is supported in FireFox and other Gecko browsers.

因此​​,要回顾一下,会是更快的传输实际的图像文件或以base64 code。难道使用Ajax时加载图像需要较少的http请求?

So to recap, would it be faster to transfer an actual image file or the base64 code. Would it require less http request when using ajax to load the images?

的图像将是不超过100个像素总

The images would be no more than 100 pixels total.

推荐答案

好吧,我不跟你们谁同意。还有当你加载更多的图像的情况。不是所有的页面包含在所有的3张照片。其实我的工作,你已经装载超过200张的网站。当用户100000申请一个非常加载网站,200的图像会发生什么。服务器的磁盘,返回图像应当塌陷。更糟糕的是你已经做了这么多请求到服务器,而不是一个使用Base64。对于这么多的缩略图我preFER为Base64重新presentation,pre-保存在数据库中。我找到了解决方案,并以强劲的论证<一个href=\"http://www.stoimen.com/blog/2009/04/23/when-you-should-use-base64-for-images/\">http://www.stoimen.com/blog/2009/04/23/when-you-should-use-base64-for-images/.这家伙真的是在这种情况下,取得了一些测试。我是IM pressed,让我的测试中也是如此。现实情况是像它说。对于在一个页面加载这么多图片来自服务器的一个响应是真正有用的。

Well I don't agree with anyone of you. There are cases when you've to load more and more images. Not all the pages contain 3 images at all. Actually I'm working on a site where you've to load more than 200 images. What happens when 100000 users request that 200 images on a very loaded site. The disks of the server, returning the images should collapse. Even worse you've to make so much request to the server instead of one with base64. For so much thumbnails I'd prefer the base64 representation, pre-saved in the database. I found the solution and a strong argumentation at http://www.stoimen.com/blog/2009/04/23/when-you-should-use-base64-for-images/. The guy is really in that case and made some tests. I was impressed and make my tests as well. The reality is like it says. For so much images loaded in one page the one response from the server is really helpful.

这篇关于基地64 CS code VS加载图像文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆