Cache warm up 

To have a website that is fast for the end-user is essential, therefore having a warm cache even before the first user hits the newly deployed website, will be beneficial, so how could one achieve this?

The crawler have some command line tools (hereafter cli tools) that can be used, during deployments. The cli tools is implemented with the symfony/console which have been standard in TYPO3 for a while.

There are 3 commands that can be of you benefit during deployments.

  • vendor/bin/typo3 crawler:flushQueue
  • vendor/bin/typo3 crawler:buildQueue
  • vendor/bin/typo3 messenger:consume crawler_high crawler crawler_low

You can see more on which parameters they take in Run via command controller, this example will provide suggestion on how you can set it up, and you can adjust with additional parameters if you like.

  1. Create crawler configuration

    First we need a crawler configuration these are stored in the database. You can add it via the backend, see Configuration records.

    It's suggested to select the most important pages of the website and add them to a Crawler configuration called e.g. deployment:

    Crawler configuration record

    Crawler configuration record

  2. Build the queue

    With this only pages added will be crawled when using this configuration. So how will we execute this from CLI during deployment? I don't know which deployment tool you use, but it's not important as long as you can execute shell commands. What would you need to execute?

    # Done to make sure the crawler queue is empty, so that we will only crawl important pages.
    $ vendor/bin/typo3 crawler:flushQueue all
    
    # Now we want to fill the crawler queue,
    # This will start on page uid 1 with the deployment configuration and depth 99,
    # --mode exec crawles the pages instantly so we don't need a secondary process for that.
    $ vendor/bin/typo3 crawler:buildQueue 1 deployment --depth 99 --mode exec
    
    # Add the rest of the pages to the crawler queue, they are processed by the worker (vendor/bin/typo3 messenger:consume crawler_high crawler crawler_low)
    # --mode queue is default, but it is  added for visibility,
    # we assume that you have a crawler configuration called default
    $ vendor/bin/typo3 crawler:buildQueue 1 default --depth 99 --mode queue
    
    Copied!
  3. Process the queue

    The last step will add the pages to the queue. They are processed by a worker consuming the crawler transports, see Running the worker:

    vendor/bin/typo3 messenger:consume crawler_high crawler crawler_low
    Copied!

With there steps you will have a website that is faster by the first visit after a deployment, and the rest of the website is crawled automatically shortly after.

#HappyCrawling