How to make a proper display of products at discounted prices when exposed to the cache?

Greetings to all.
The site has the component bitrix:catalog caching enabled. When displaying the price of goods without discount is no problem, and when a rule is created for the cart (discount) that would correctly display the discount rates it is necessary to reset the cache. Option every time to reset cache (automatically or by hand) is not suitable, because cached about 25,000 products.
What you need to do that properly discounted prices, with frequently changing rules for basket (discounts) when caching is enabled.
Support Bitrix didn't help.
June 3rd 19 at 19:41
4 answers
June 3rd 19 at 19:43
And rightly so, that is not suggested.
The rules of basket depend not only on the product but also other conditions.

The easiest and most straightforward option how to do it: subscribe to d7 events and updates the cache component.
You are interested in events:
- \Bitrix\Modules\Sale\Internals\Discount::onAfterAdd (after creation)
- \Bitrix\Modules\Sale\Internals\Discount::onAfterUpdate (after update)

How to clear the cache:
- https://dev.1c-bitrix.ru/api_help/main/functions/o...
- https://dev.1c-bitrix.ru/api_help/main/reference/c...
Left a comment at xzdshr. View - patience.Fisher commented on June 3rd 19 at 19:46
I don't see a problem aggerate necessary elements and when upgrading via the api reset cache only modified items - Roel.OConnell30 commented on June 3rd 19 at 19:49
Us shares are distributed to the sections in which many elements - patience.Fisher commented on June 3rd 19 at 19:52
it does not matter) need to Clean.

The only thing - to make a ajax loading rates. Type display the old, and in front of her like a little grey preloader that every N-th time actualizes the price. - Roel.OConnell30 commented on June 3rd 19 at 19:55
June 3rd 19 at 19:45
Option every time to reset cache (automatically or by hand) is not suitable

"Are U sure about that?"

Is the page in the cache. Price is changing. Page is returned from the cache with the same price. Everything is logical.
If you change the discount it is NECESSARY to reset the cache. Who cares how many goods? The cache page will be recorded when you first hit, not when you change discounts.
We have a discount bundle are created using API, and then change over time. I understand with every change to clear the cache Gigabyte(? - patience.Fisher commented on June 3rd 19 at 19:48
if a pack, then you can just create some endpoint, which will trigger a cache cleanup.
He did so many takes? You only need a specific component to clean, not the whole cache.
Hereunder even if the cache component of the gig is, it's okay. It purifies the request to the API and not the clients, so that clients should not be affected. Just the first one coming on not yet cached the page will wait for her longer than all subsequent ones. - Roel.OConnell30 commented on June 3rd 19 at 19:51
Well, plus, if you frequently menyat, it is unlikely GB cache coming up, right? - patience.Fisher commented on June 3rd 19 at 19:54
June 3rd 19 at 19:47
Oh, dear friend, welcome to the world of perversion and crutches.
1. Start childblock in which to write the id of the product and its price at the time of the work component of the directory before generating the cache, the cache necessarily tigerweb. And hang on Kron processor which constantly runs and checks the prices (including user groups), if the price received does not correspond to the recorded hiloudaki, then reset the corresponding cache tag.

2. in the caching key products to add a date change the rules of the basket. Date changed => the cache is out of date.

3. all region with the display of prices in the templates to load Ajax (analog composite mode).
I already knew that he was in the wonderful world of Bitrix).
1. Read about tegirmenty cache and about "key cache"
3. Ajax have already loaded other product characteristics that create not sickly load on the server. - patience.Fisher commented on June 3rd 19 at 19:50
,
Ajax have already loaded other product characteristics that create not sickly load on the server.

do with the slave database on a single server and all requests of this kind wrap, there will be read-only, such requests can be good to cache unload the main server. - Roel.OConnell30 commented on June 3rd 19 at 19:53
In the 2nd paragraph under "key caching" meaning $arParams["PAGER_PARAMS_NAME"]. I.e. in this option, you must insert the date of the change rules of trash? - patience.Fisher commented on June 3rd 19 at 19:56
June 3rd 19 at 19:49
Apparently universal solution would be:
BXClearCache(false, "/s1/bitrix/catalog.section/");
(new \Bitrix\Main\Data\ManagedCache())->cleanAll();
(new \CStackCacheManager())->CleanAll();

making changes and adding discounts

Find more questions by tags 1C-Bitrix