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:
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.
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.
Whether it is stored in the same size, it may involve disk read/write performance? I don't know much about this.
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.