L
L
lazix2020-11-27 12:35:57
Browsers
lazix, 2020-11-27 12:35:57

Is it acceptable to use base64+mod_gzip to transfer and display pictures from 1C to Bitrix?

1C uses the HTML description module, which stores embedded images in product descriptions as base64. Accordingly, then this info is transmitted to the side of the site on Bitrix, where base64 is already displayed in the browser.

Base64 increases the size of the image by about a third, and mod_gzip compresses the html code of the page back. The result is about an average of 1% overhead according to my experiments: a 100 KB picture turns into a 133 KB code, which will be compressed into 101 KB during transmission.

Is such a scheme acceptable, in your opinion? Are my assumptions correct?
My concern is:
1. Is there an error?)
2. The browser will not be able to cache such images?

PS. Rewriting the code for storing images in files and subsequent exchange with Bitrix is ​​not economically justified.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Prilepsky, 2020-11-27
@Prilepsky

If it works and the exchange is not every 5 seconds, then why not?
The information in the goods, especially the images, change extremely rarely and there is not much point in saving KB.
I won’t say for sure about caching, but I myself used this technique for storing small images in CSS for a long time, I know that many people did this. But how he is now - I will not tell you anymore :)

A
Alexander, 2020-11-27
Madzhugin @Suntechnic

1. Is there an error?)

Errors in what?
2. The browser will not be able to cache such pictures?

It's not that he can't - he won't, because it's pointless.
Let's imagine that the browser cached all these pictures in the dataurl... so what? Will they now magically disappear from the page you pass to the browser? No. The server still embeds them into the page and the browser still downloads it in its entirety. And why did he cache them then?
A cache is always some heavy data associated with some short key. For example an image file with its URL. Seeing the URL in the page, the browser will not download the file, but will take it from the cache.
In your case, the URL is the file itself - no saving is possible here.
The advantage of dataurl is that images are displayed much earlier as they are loaded along with the page or styles.
The disadvantage is that they are downloaded every time a page needs to be loaded.
So whether it's good or bad depends on your site's usage scenario.
If the client loads the product page only once, looks at the prices and closes the tab in horror, then the losses will really be in the region of several percent. If several times ... well, let's count.
Let the page size be 200Kb and there are 2Mb more images on it. Then in the classical situation, the first page load will be ~ 2200Kb, and all subsequent 200Kb. In your case, all downloads will be 2200Kb.
Thus, if the client visits the page once, there is no difference. If two - then the additional costs will be 83%, if 4 times - 215% of excess traffic from above.
But it all depends on repeated views and the size of your pictures and the ratio of this size to the size of the page.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question