We use M2.4.2
We synchronize our stock quantities by REST API every 15 minutes. The problem that results out of that is that the full page cache (built-in) of all pages (category, product, cms) gets flushed every 15 minutes. It seems to be that this occurs also when an order is marked as shipped (but not absolutely sure).
We looked for a solution which avoids the automatic cache flush. Best case would be that only the product cache of the changed quantity and it’s parent products get flushed.
We wouldn’t need that category pages get flushed. Only the product for which the quantity was changed.
It seems that some others face the same issue. Here someone says that it has something to do with the top menu: https://github.com/magento/magento2/issues/21385
Or here someone tried to stop the caching and only flushed when needed: Magento 2 Rest Api is clearing cache too frequently on product updates
But no real solution which worked.
I took a look at modules InventoryCache, PageCache, but didn’t find the right point to start
Does anybody have a solution?
2
Answers
In Magento when products are edited for QTY or any other action then associated Mview table values and CL tables are impacted.
When Cron runs it checks these table and based on the version on Mview table and entries in CL table products are indexed.
When a product is indexed all its cache is flushed.
Also category pages have product ID tags associated so these cache also gets flushed out.
Set indexing on save instead of indexing on schedule.
See if that works but it can have its own side effect as when you import indexing might not happen.
Also share whats the setting related to inventory.
EDIT: My issues stem from some modules that are set to update on schedule, unfortunately those modules clear the fpc cache constantly. Example Amasty Sorting effectily prevented FPC from ever being fully generated. Swissup Checkout Fields wipes FPC on order save. All very frustrating.
FPC is effectively useless after you go through and see that no more than about 5% of a the stores URL’s are cached before it’s cleared.
If the Magento FPC didn’t clear constantly, it would be absolutely rocket fast. But even new prduct reviews clears the entire FPC. Modules that are also checking for notifications wipe the FPC.