Magento 2 Full Page Cache Documentation

  • Installation

    You can install the module for Magento 2 using Composer or you can manually install it using FTP.

    Composer

    Run the following commands in your Magento 2 root directory to install the module using Composer.

    # Add the FishPig Composer repo
    composer config repositories.fishpig composer https://repo.fishpig.com/
    
    # Install the module using Composer
    composer require fishpig/magento2-bolt:*
    
    # Enable the module in Magento 2
    php bin/magento module:enable FishPig_Bolt
    
    # Run the Magento upgrade system
    php bin/magento setup:upgrade
    Manual

    You can download the latest version of the module by logging in to your account and selecting Account > Projects.

    Extract the ZIP file and upload the files to your Magento site at the directory below:

    When creating the folders, ensure you use the correct capitalisation.

    To complete the installation, run the following commands in a terminal.

    # Enable the module in Magento 2
    bin/magento module:enable FishPig_Bolt
    
    # Run the Magento upgrade system
    bin/magento setup:upgrade

    After installing the module, you can enable the Bolt FPC cache using the following CLI command:

    bin/magento cache:enable bolt_fpc

    Index.php

    From version 2.6 of Bolt FPC, you no longer need to modify index.php. If you have a modification in index.php from a previous version, this will no longer be used. You can remove it or leave, it won't make a difference. If possible though, remove it to ensure clean code.

    ↑ Back to Top

  • Configuration

    The Full Page Cache module comes ready configured but if you want to make any changes, you can do so in the Magento Admin by selecting: Stores > Configuration > FishPig > Bolt FPC.

    Multistore

    Bolt fully supports Magento multistore and you do not have to make any configuration changes for Bolt to run in a multi-store environment. Bolt FPC will correctly cache content for each store.

    Cache Backends

    Bolt uses it's own file based cache backend. This is optimised for Magento 2.

    Troubleshooting

    To check that Bolt is running and has cached the current page, use your browsers developer tools to check the headers of the HTTP Response. When Bolt has cached a page, the x-bolt-id header will be set. If this header is not set then the current page has not been retrieved from the cache.

    ↑ Back to Top

  • Hole Punching

    The more that can be cached on a page, the faster it will be. Unfortunately it's not always possible to cache the whole page as certain sections are completely dynamic and unique to each user. To get around this, Bolt FPC uses a hole punching system.

    What is Hole Punching?

    Hole punching is a system that allows you to mark certain sections of a page to be loaded each time and never cached while still caching the rest of the page. Bolt will load a page from the cache and then fill in the holes with dynamic content. In Magento, the most common block to be hole punched is the header, as this usually contains dynamic content such as a shopping cart summary and different links depending on whether the customer is logged in or not. As this is such a commonly hole punched block, Bolt will hole punch this block automatically so you don't need to add this to the hole punch list.

    Configuring Hole Punching

    Hole punching is disabled by Bolt but can be enabled via the Bolt FPC config. Once enabled, you can specify block layout names in the config and these will be automatically hole punched.

    ↑ Back to Top

  • Cli Commands

    The module comes with a handy command line utility that allows you to flush the whole cache or just specific URLs easily.

    Empty the Cache

    The below command will empty the whole cache. This includes all pages from all stores/websites.

    bin/magento fishpig:bolt:flush

    Remove Specific URLs from the Cache

    If you don't want to remove everything from the cache but just want to remove a single URL, you can do so by passing options to the flush command.

    --url

    You can specify as many URL arguments as you like. The URL should be a relative URL.

    bin/magento fishpig:bolt:flush --url=/mens/jackets.html

    You can specify multiple URLs in a single command.

    bin/magento fishpig:bolt:flush --url=/mens/jackets.html --url=/womens/jackets.html

    By default, all child pages of a given URL are flushed from the cache. This includes all different variations of the page (ie. query string parameters).

    --store

    By default, the URL will be removed from the cache for every store. You can limit the stores using the store option.

    bin/magento fishpig:bolt:flush --url /mens/jackets.html --store=1 --store=2

    Flush a Whole Website Section

    Let's say you have a Magento WordPress integrated blog on your site that is available from /blog and you want to flush the whole blog from the cache. The following command will do that:

    bin/magento fishpig:bolt:flush --url=/blog --deep

    This will flush the /blog URL but also flush all children URLs of /blog and will empty all of the blog from the cache for every store. You can limit this to a specific store with the stores option (see above).

    ↑ Back to Top