What is Caching?
In computing, a cache is a high-speed data storage layer that stores a subset of data, typically transient in nature, so that future requests for that data are served up faster than is possible by accessing the data’s primary storage location. Caching allows you to efficiently reuse previously retrieved or computed data.
How caching is implemented in Magento?
The Magento page cache library contains a simple PHP reverse proxy that enables full page caching out of the box. A reverse proxy acts as an intermediary between visitors and your application and can reduce the load on your server.
Magento's default caching mechanism provides different storage options that store cached data in 3 different sources:
- File System
- Database
- Redis
<block cacheable="false" class="Magento\Customer\Block\Form\Edit" name="customer_edit" template="Magento_Customer::form/edit.phtml">
<container as="form_additional_info" name="form.additional.info">
</container></block>
NOTE: A developer should always take care that this code should not be added in the default.xml file or any other layout file which is added across the website. Because this code is added in the layout, then that makes the complete page uncacheable.
Different Cache Commands
Magento has provided different commands to execute different cache operations. They are below:
- php bin/magento cache:status: This command is used to check the status of the individual cache types.
- php bin/magento cache:enable: This command is used to enable the cache. You can pass cache type as parameter in the command as below:
php bin/magento cache:enable [type] ... [type]
- php bin/magento cache:disable: This command is used to disable the cache. You can pass cache type as parameter in the command as below:
php bin/magento cache:disable [type] ... [type]
- php bin/magento cache:clean: This command is used to clear the cache. You can pass cache type as parameter in the command as below:
php bin/magento cache:clean [type] ... [type]
- php bin/magento cache:flush: This command is used to remove the cache. You can pass cache type as parameter in the command as below:
php bin/magento cache:flush [type] ... [type]
NOTE: The type option is a space-separated list of cache types.
Difference Between Cache Clean & Cache Flush
- Cache Clean: This command deletes all the enabled magento related cache. And does not impact the other stored data in the same storage.
- Cache Flush: This command deletes all the magento related cache and also delete all the other stored data in the same storage. This might impact the other applications which are using the same storage for caching.
Comments
Post a Comment