How many KB images (such as user portraits) in the API should be put into the JSON stream?

Source: Internet
Author: User
In the RT design of the client-server interaction API, what should I do with the trivial pictures of several KB? How to Design the cache mechanism for these small images on the client? How can I store these small images on the server? What should I do with images that are not big (10 + KB? RT
In the design of the client-server interaction API, what should I do with the trivial pictures of several KB?

  • How to Design the cache mechanism for these small images on the client?
  • How can I store these small images on the server?
  • What should I do with images that are not big (10 + KB?

Reply content:

RT
In the design of the client-server interaction API, what should I do with the trivial pictures of several KB?

  • How to Design the cache mechanism for these small images on the client?
  • How can I store these small images on the server?
  • What should I do with images that are not big (10 + KB?

JSON stream?

Do you mean to pass those images to the client through the json api after Base64 Encodeing processing?

If this is the meaning, there are both advantages and disadvantages. Let's briefly talk about some of your questions:

  1. Generally, trivial pictures of several KB can be transmitted quickly after encoding. Of course, if the amount is not up, the difference is very small.

  2. Unfortunately, if you do not directly request a binary file, Data URI cannot be cached on the client. Whenever the document changes, they must be downloaded again.

  3. Whether it is stored in the same size, it may involve disk read/write performance? I don't know much about this.

  4. Not big ...... How can this be defined? Is it necessary to design a system that targets the image size and size in the upper, lower, and lower grades? I think static resources can be processed independently by CDN, And the API returns the request CDN address to the client. This is the most mature method at present. For small items, icons and the like are generally used, either sprites or directly converted into fonts.

Do not use base64 for more than 200 bytes. Believe in the power of gzip.
I believe that the size after binary serialization is about twice as large as that after binary serialization.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.