Magento 2 Full Page Cache: Speed Up Your Site
What is Magento 2 Full Page Cache?
The term defines the storage of the full page output in a cache. The function is implemented to make the subsequent page load faster without much server load. Due to Magento full page cache settings availability in the second version, a site will display category, product, CMS pages quicker. A response time is improved a lot through reducing the page load on the server or Magento full page cache auto generation. This means there is no need for each page to run blocks of code and retrieve information from the database. Thus, the load time reduces and the data is received faster. The speed enhancement improves the visit depth, conversion, and the website’s Google position.
How to disable full page cache in Magento 2?
To disable full page cache in Magento 2, type the bin/magento cache:disable full_page command in the command line or admin. As a result, you will get the message: Changed cache status: full_page: 1 -> 0. After this, flush the cache, as usual, using the php bin/magento cache:flush command.
How to enable all cache through the command line in Magento 2?
To enable all cache using Magento 2 command line, enter the following command: php bin/magento cache:enable. If you want to turn on specific cache types, enter them separated by spaces.
What are Magento full page cache settings?
Magento full page cache settings depend on the caching application you use Built-in Application or Varnish Caching. However, Varnish is a Magento-recommended solution. If you use it, you need to fill in the Access list, Backend host, Backend port, and Grace period or export the settings.
How to enable full page cache auto-generation in Magento 2?
If you want to enable Magento full page cache auto-generation, install our Full Page Cache Warmer extension. This module helps you automate the process of cache warming and speed up your website loading.
How to clear Magento cache programmatically?
If you need to clear the Magento cache programmatically, use the php bin/magento cache:clean [type] or php bin/magento cache:flush [type] command. In case you need to clean all types of cache at once, just skip the [type] part.
How to Configure Full Page Cache in Magento 2?
- Log in to your Admin Panel;
- Go to Stores>Settings>Configuration;
- Choose the option ‘System’ in the ‘Advanced’ drop-down menu on the left;
- Enter the ‘Full Page Cache’ section:
- Select ‘Built-in Application’ or ‘Varnish Caching’ in the Caching Application filed:
Magento 2 is supplied with numerous advantageous built-in features and the ‘Built-in Application’ is just one of them. However, Varnish is a Magento recommended solution. Here are some basic tips to rely on when choosing a right option: Varnish caches static files as well, which allows for avoiding the database and filesystem slowing; Varnish cache is not primarily developed for working with Magento; Varnish can cache most of a website’s content and works faster; the built-in application is useful when working in the development mode; Varnish is recommended when working in the production mode.
- In the TTL for public content field set the expiration time for the page cache. 86400 is a default value:
If you have chosen ‘Varnish Caching’ you need to complete all the configurations. If Magento 2 full page cache is not working, make sure you followed all the steps correctly. See here for more setting details.
Helpful tip: Keeping your full page cache warm can help you speed up the website loading and, as a result, increase conversion rate. Our Full Page Cache Warmer extension has 5 algorithms that help you prioritize pages for cache warming. With this plugin, the warming process will be fully automatic. Just configure the module and schedule the cron job to generate the cache warming queue.
Magento 2 Cache Management
The cache management includes at least 3 main actions that you can do via command line:
- view the Magento 2 cache status;
- enable/disable Magento cache types;
- clean and flush cache types.
Firstly, log in to Magento server as the Magento file system owner.
If you run the bash shell, you can switch to the file system owner using the following syntax:
su <Magento file system owner> -s /bin/bash -c <command>
If you still can’t log in, do the next:
sudo -u <Magento file system owner> <command>
If you want to run the command from any directory use <your Magento install dir>/bin to your system PATH.
Then choose what activity you need:
View the cache status
To view the status of your Magento 2 cache, enter the following:
You will see the information like follows:
Enable/disable cache types
All Magento 2 cache types can be enabled or disabled through the command line. The cache type disabling is useful when working in the development mode, as long as you can see all the made changes without flushing the cache. Nevertheless, this action affects badly the performance.
Use the commands to enable/disable the cache:
magento cache:enable [type] ... [type]
magento cache:disable [type] ... [type]
If you omit [type] ( a list of cache types) here the functions will be applied to all cache types simultaneously. If you want to list the cache types and their statuses, use:
Thus, if you need to disable the full page cache type in Magento 2, enter:
magento cache:disable full_page
You will see the next result:
Changed cache status:
full_page: 1 -> 0.
To enable the disabled cache type automatically, clear the cache type.
Or, you can also enable or disable cache in Magento 2 Backend. For this, go to System > Tools > Cache Management. There you will see the list of used cache types and their statuses. Select what cache you want to disable or enable and choose the needed option from the action dropdown. Click on the submit button. After that, check that the status of the cache types was successfully changed.
Clean and flush cache types
To went off the old items from the cache, you need to clean or flush the cache types.
The cache type cleaning is used for deleting all items from the enabled cache types only. Thus, the process doesn’t affect other applications and disabled types, as long as it cleans only the cache used by Magento.
The cache type flushing clean the cache storage. Thus, other applications that use the same storage can be affected. The way of cleaning is suitable in case you still come up with issues you can’t solve.
You can clear cache programmatically in Magento. Use the following commands to run the options:
magento cache:clean [type] ... [type]
magento cache:flush [type] ... [type]
Having made flush, you’ll get the such-like result:
Flushed cache types:
The cache types can be cached in the Magento Admin too. Enter System>Tools>Cache Management and choose a necessary option either Flush Magento Cache (magento cache:clean) or Flush Cache Storage (magento cache:flush).
According to the statistics, you may find helpfull the following question about message queue.