Every day I login to Magento Admin panel, I get a message like Magento page cache invalidated. How can i fix this?
That was a recent support ticket we received at our Outsourced Technical Support department where we resolve support queries for web hosting providers.
Magento website owners see the below warning or an alert in their Magento admin panel.
One or more of the Cache Types are invalidated:Page Cache. Please go to Cache Management and refresh cache types.
This can be quite frustrating when you see this error every day.
What’s wrong here?
Today, let’s discuss more about the causes of this warning and how our Dedicated Support Engineers fix them.
What’s ‘Page Cache’ and ‘Cache invalidate’?
These are the 2 words that we use frequently in this article.
So, let’s start with the terms “Page Cache” and “Cache invalidate“.
Page Cache
Magento uses Full Page Caching to quickly display category, product and CMS pages.
Without caching, a page must run blocks of code and retrieve the information from database each time.
However, with Page cache enabled, this page can be fetched directly from the cache.
As a result, it drastically improves the website performance and server load.
Cache Invalidate
Simply put, this indicates that changes have been made to your site, and the system recognized that these changes don’t match the data in the cache.
Therefore, the system marks the cache contents as invalid.
Reasons for Magento page cache invalidated error
Based on our experience dealing with Magento problems, we’ve seen 2 cases where Magento invalidates Page cache and users see this warning.
- Magento website owners often make changes or updates to products, categories, catalog price rules, static blocks, 3rd party extensions, etc.
- Website owners use cron jobs in their Magento application to update catalog price rules, currency rates, etc.
So, when you make changes to your website, Magento will trigger events.
There are listeners for these events and they identify that the data in database no longer matches the data in the cache.
As a result, this invalidates the cache and displays the warning “One or more of the Cache Types are invalidated“.
How to fix Magento page cache invalidated error?
The solution is to clear the Magento cache.
That is, Magento needs to re-build all the cache files anytime a product change is made as part of the core system.
This is to ensure that these changes appear on your site.
Now, let’s see the steps to clear Magento cache.
You can clear the cache in 2 ways – automatically or manually and the exact steps varies depending on the Magento version.
We’ll discuss the steps to clear the cache in Magento 2 and older versions.
i) In Magento 2
Our Hosting Engineers clear Magento cache either via Magento admin panel or SSH.
Via Magento admin panel
We clear the Magento cache from admin panel using the below steps.
- Go to System > Cache Management
- Click on Flush Magento Cache.
- Further, click on Flush Cache Storage.
Via SSH
Similarly, we can clear the cache from command line as well.
After logging into user’s account via SSH, we execute the following commands in the Magento installation directory.
php bin/magento cache:clean
php bin/magento cache:flush
First command removes all enabled cache related to Magento and second command deletes whole cache irrespective of Magento cache or any third party cache.
ii) In Magneto 1.x
Similar to Magento 2, you can clear the cache in Magento 1.x either via admin panel or SSH.
Via Magento admin panel
We clear the Magento cache from admin panel using the below steps.
- Go to System > Cache Management.
- Click on Flush Cache Storage.
Via SSH
Magento stores the cache files in var/cache folder located in the Magento installation directory.
So, to clear the cache, the files in the var/cache directory should be deleted.
Our Hosting Engineers remove the contents from this folder after logging into the user’s account via SSH.
For example, we remove the files from var/cache directory using the below command.
rm -rf var/cache/*
For large website owners who make frequent modifications to the site, we suggest to create a cron job(time based job scheduler) to flush the cache.
At Bobcares, we assist our customers in setting up cron job to automatically clear the cache and re-index the site at regular intervals like every 30 mins, every 1 hr and so on.
Conclusion
Website owners often face “Magento page cache invalidated” problem when they make changes to products, categories, catalog price rules, etc in their websites. Today, we’ve discussed how our Dedicated Support Engineers fix this problem.
0 Comments