How to Clear the Cache in Magento 2
What is it?
To understand in detail what the cache is, we need a premise: the front-end displayed to the user browsing the site is nothing more than HTML, CSS and JS code, which can either be written exactly as it is displayed or be the output of more complex code processed by the server.
To avoid the server receiving a complex request from every user who visits the site and having to perform the same operations over and over to recreate the same code, a cache is used, which stores the server’s response in physical files. This way, if the request has already been made, the code saved in the file is returned directly, saving server resources.
Most websites, and in particular all sites built with Magento, use a cache in order to improve performance.
Magento has a sophisticated cache layer: through some information added in the code, it allows you to exclude certain blocks from the cache, for example blocks that must be dynamic because they follow logic that has to change depending on the user browsing the site.
Where do I find cache management in Magento 2?
As we can see in the following image, in the System menu in the admin panel, we have the section Tools => Cache Management

Clicking the link takes us to the following screen, where we find a grid showing the status of the caches, which can be either OK or invalidated and therefore in need of being cleaned.
If plugins that use additional caches beyond the basic Magento ones are installed, we may find other rows in the table dedicated to those specific caches.
There are several ways to clean the cache. The “Flush Cache Storage” button cleans the collections and all the information related to the data and database side.
The “Flush Magento Cache” button, on the other hand, does a general cleanup of all the site’s caches.
Another option is to tick the checkbox of one or more caches in the grid and then use the submit button at the top left of the grid to run the action selected in the dropdown.

At the bottom of the grid, instead, there is a section about additional caches: image caches, JS and CSS caches (for example when they are merged), and static files. These types of cache rarely need to be cleaned.

Finally, we can clean the caches using the commands provided by the Magento shell. Of course, to do this we need SSH access to the server where the site is hosted.
Here are the commands, to be typed in the directory where the Magento code is located:
php bin/magento cache:clean || php bin/magento c:c
php bin/magento cache:flush || php bin/magento c:f