开发者

Handling data URIs for images in a dynamic site

I'm looking to cut down on HTTP requests for a mobile site and, as part of this, would like to utilise da开发者_运维百科ta URIs for sending images inline. Each page may load up to 12 thumbnails at a time, which are likely to change on refresh.

Basically i have 2 options; running base64_encode on the images on a per-request basis, or storing the encoded data in a DB and fetching that. The latter would involve a bit more work as the thumbnails may be updated periodically, so ideally I'd like the first solution, but only if the performance of base64_encode is such that it can handle encoding 12 thumbnails per page.

I'd be appreciative of any thoughts.


You should serve your image as plain image file, but from a separate domain. Because of how files are serve to the client, using a domain for images or medias could be more appropriate.

Also you should check caching server like Squid : http://www.squid-cache.org/

Just store in your database the file path.

Hope it will help you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜