Magento 2 - why is the cache cleared several times a day?

#1
Hello,
as you can read in the title, i'm trying to understand why the cache on a magento 2 server is deleted several times a day.
I've already turned on the debug log and keep checking the log to find the reason, but without success until now.

Below is a snippet from the log.
Maybe this is the crucial point:

PHP:
#0 /home/xxx/public_html/vendor/litespeed/module-litemage/Observer/FlushCacheByCli.php(154): Litespeed\Litemage\Helper\Data->debugTrace()
#1 /home/xxx/public_html/vendor/litespeed/module-litemage/Observer/FlushCacheByCli.php(91): Litespeed\Litemage\Observer\FlushCacheByCli->_shellPurge()
#2 /home/xxx/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Litespeed\Litemage\Observer\FlushCacheByCli->execute()
#3 /home/xxx/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod()
#4 /home/xxx/public_html/vendor/magento/framework/Event/Manager.php(65): Magento\Framework\Event\Invoker\InvokerDefault->dispatch()
#5 /home/xxx/public_html/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch()
#6 /home/xxx/public_html/vendor/litespeed/module-litemage/Observer/FlushCacheByTags.php(66): Magento\Framework\Event\Manager\Proxy->dispatch()
#7 /home/xxx/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Litespeed\Litemage\Observer\FlushCacheByTags->execute()
#8 /home/xxx/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod()
#9 /home/xxx/public_html/vendor/magento/framework/Event/Manager.php(65): Magento\Framework\Event\Invoker\InvokerDefault->dispatch()
#10 /home/xxx/public_html/vendor/magento/module-indexer/Model/Indexer/DeferredCacheCleaner.php(73): Magento\Framework\Event\Manager->dispatch()
#11 /home/xxx/public_html/vendor/magento/module-indexer/Model/Processor/CleanCache.php(50): Magento\Indexer\Model\Indexer\DeferredCacheCleaner->flush()
#12 /home/xxx/public_html/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Indexer\Model\Processor\CleanCache->afterUpdateMview()
#13 /home/xxx/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Indexer\Model\Processor\Interceptor->Magento\Framework\Interception\{closure}()
#14 /home/xxx/public_html/generated/code/Magento/Indexer/Model/Processor/Interceptor.php(41): Magento\Indexer\Model\Processor\Interceptor->___callPlugins()
#15 /home/xxx/public_html/vendor/magento/module-indexer/Cron/UpdateMview.php(31): Magento\Indexer\Model\Processor\Interceptor->updateMview()
#16 [internal function]: Magento\Indexer\Cron\UpdateMview->execute()
#17 /home/xxx/public_html/vendor/wyomind/cronscheduler/Plugin/Cron/Observer/ProcessCronQueueObserver.php(397): call_user_func_array()
#18 /home/xxx/public_html/vendor/wyomind/cronscheduler/Plugin/Cron/Observer/ProcessCronQueueObserver.php(904): Wyomind\CronScheduler\Plugin\Cron\Observer\ProcessCronQueueObserver->_runJob()
#19 /home/xxx/public_html/vendor/wyomind/cronscheduler/Plugin/Cron/Observer/ProcessCronQueueObserver.php(867): Wyomind\CronScheduler\Plugin\Cron\Observer\ProcessCronQueueObserver->tryRunJob()
#20 /home/xxx/public_html/vendor/wyomind/cronscheduler/Plugin/Cron/Observer/ProcessCronQueueObserver.php(319): Wyomind\CronScheduler\Plugin\Cron\Observer\ProcessCronQueueObserver->processPendingJobs()
#21 /home/xxx/public_html/generated/code/Wyomind/CronScheduler/Plugin/Cron/Observer/ProcessCronQueueObserver/Interceptor.php(23): Wyomind\CronScheduler\Plugin\Cron\Observer\ProcessCronQueueObserver->aroundExecute()
#22 /home/xxx/public_html/vendor/magento/framework/Interception/Interceptor.php(135): Wyomind\CronScheduler\Plugin\Cron\Observer\ProcessCronQueueObserver\Interceptor->aroundExecute()
#23 /home/xxx/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cron\Observer\ProcessCronQueueObserver\Interceptor->Magento\Framework\Interception\{closure}()
#24 /home/xxx/public_html/generated/code/Magento/Cron/Observer/ProcessCronQueueObserver/Interceptor.php(23): Magento\Cron\Observer\ProcessCronQueueObserver\Interceptor->___callPlugins()
#25 /home/xxx/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): Magento\Cron\Observer\ProcessCronQueueObserver\Interceptor->execute()
#26 /home/xxx/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(74): Magento\Framework\Event\Invoker\InvokerDefault->_callObserverMethod()
#27 /home/xxx/public_html/vendor/magento/framework/Event/Manager.php(65): Magento\Framework\Event\Invoker\InvokerDefault->dispatch()
#28 /home/xxx/public_html/generated/code/Magento/Framework/Event/Manager/Proxy.php(95): Magento\Framework\Event\Manager->dispatch()
#29 /home/xxx/public_html/vendor/magento/framework/App/Cron.php(86): Magento\Framework\Event\Manager\Proxy->dispatch()
#30 /home/xxx/public_html/vendor/magento/module-cron/Console/Command/CronCommand.php(117): Magento\Framework\App\Cron->launch()
#31 /home/xxx/public_html/vendor/symfony/console/Command/Command.php(255): Magento\Cron\Console\Command\CronCommand->execute()
#32 /home/xxx/public_html/vendor/magento/framework/Interception/Interceptor.php(58): Symfony\Component\Console\Command\Command->run()
#33 /home/xxx/public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Cron\Console\Command\CronCommand\Interceptor->___callParent()
#34 /home/xxx/public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Cron\Console\Command\CronCommand\Interceptor->Magento\Framework\Interception\{closure}()
#35 /home/xxx/public_html/generated/code/Magento/Cron/Console/Command/CronCommand/Interceptor.php(23): Magento\Cron\Console\Command\CronCommand\Interceptor->___callPlugins()
#36 /home/xxx/public_html/vendor/symfony/console/Application.php(1021): Magento\Cron\Console\Command\CronCommand\Interceptor->run()
#37 /home/xxx/public_html/vendor/symfony/console/Application.php(275): Symfony\Component\Console\Application->doRunCommand()
#38 /home/xxx/public_html/vendor/magento/framework/Console/Cli.php(116): Symfony\Component\Console\Application->doRun()
#39 /home/xxx/public_html/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun()
#40 /home/xxx/public_html/bin/magento(23): Symfony\Component\Console\Application->run()
The Server is running in production mode on Magento 2.4.5
I'm very thankful for every answer! :=)

Best regards
 

AndreyPopov

Well-Known Member
#2
@KFSOL check what
Magento\Indexer\Cron\UpdateMview->execute() to do

remember, by default
LSCache plugin purge cache after add/delete and edit page
#6 /home/xxx/public_html/vendor/litespeed/module-litemage/Observer/FlushCacheByTags.php(66): Magento\Framework\Event\Manager\Proxy->dispatch()

what cache purged? private or public?

by default
private cache TTL is 3600 secs
public cache TTL usually is 10 days (864000 secs)
 
#3
@AndreyPopov thanks a lot for you fast answer!
If I unterstand it correctly Magento\Indexer\Cron\UpdateMview->execute() describe that a reindex was scheduled.

Shouldn't only the individual page be deleted from the cache when changes are made to a single page?
I always look at the SUB-URL DOMAIN/__LSCACHE/STATS and see that the LITEMAGE_OBJS go to 0 serveral times a day.
It think "LITEMAGE_OBJS" is an indicator for both public and private cache objects right?
So I think my problem is that both cache types are flushed.

Configurations in magento backend:
- increased public cache TTL to 30 Days (2592000 secs)
- enabled custom vary with yes and enforce vary checking on first visit

Configuration in .htaccess:
Code:
<IfModule LiteSpeed>
    LiteMage on
    RewriteCond %{HTTP_USER_AGENT} "android.+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|iP(hone|od)|iris|kindle|lge |maemo|meego.+mobile|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|(Android.+Mobile)|NOKIA|SymbianOS|N900|BlackBerry"
    RewriteRule .* - [E=Cache-Control:vary=ismobile]
    CacheIgnoreCacheControl On
    CacheMaxExpire 2592000
    CacheMaxFileSize 6400000
</IfModule>
 

AndreyPopov

Well-Known Member
#4
@KFSOL

I think
Code:
RewriteCond %{HTTP_USER_AGENT} Android|iPhone [NC]
is enough for detect mobile devices at today conditions ;)
this cover 99% of mobile devices





Shouldn't only the individual page be deleted from the cache when changes are made to a single page?
no. by default after "save" cache purged for all pages at same level (category)


I'm using Opencart.

some knowledge about WordPress plugin. and for example
https://docs.litespeedtech.com/lscache/lscwp/cache/#purge-tab
by default
Auto Purge Rules for Publish/Update
 
Last edited:
Top