Feb 05. 2019 · by Helge Sverre

Lightning-fast Craft CMS sites with full page caching on Laravel Forge using Blitz

I'm going to blow your mind, with this guide.

First we need to install the Blitz plugin

Installing Blitz
# Require with composer
composer require putyourlightson/craft-blitz

# Enable the plugin
php craft install/plugin blitz

Then we need to change our configuration files, you can change all of these in the Control Panel, but I prefer to have things like this in a dedicated configuration file, to use different settings in different environments.


return [
    '*' => [
        // Whether static file caching should be enabled.
        'cachingEnabled' => true,
    'dev' => [
        // No need for caching in development
        'cachingEnabled' => false,
    'production' => [
        // Whether the cache should automatically be warmed after clearing.
        'warmCacheAutomatically' => true,

        // Whether URLs with query strings should cached and how.
        // 0: Do not cache URLs with query strings
        // 1: Cache URLs with query strings as unique pages
        // 2: Cache URLs with query strings as the same page
        'queryStringCaching' => 1,

        // The relative path to your cache folder from your public webroot.
        'cacheFolderPath' => 'cache/blitz',

        // The max number of multiple concurrent requests to use when warming the cache. The higher the number, the faster the cache will be warmed and the more server processing will be required. A number between 5 and 20 is recommended.
        'concurrency' => 5,

        // The URI patterns to include in static file caching. The second variable represents a site ID, or a blank string for all sites.
        'includedUriPatterns' => [
            // TODO: Cache everything, change this if not appropriate

        // The URI patterns to exclude from static file caching (overrides any matching patterns to include). The second variable represents a site ID, or a blank string for all sites.
        'excludedUriPatterns' => [
            // TODO: Fill out, example, contact forms thank you pages or dynamic sites that show user data
            // Example: ["/contact/thanks"], ["/profile"]

        // Whether an `X-Powered-By: Craft CMS, Blitz` header should be sent.
        'sendPoweredByHeader' => false,

        // Whether the cache should automatically be warmed after clearing globals.
        'warmCacheAutomaticallyForGlobals' => true,

Then we need to change our general.php config file to disable the craft cache tag, as it does not play nice with the Blitz plugin cache.


return [
    // More config up here that is not important...

    // Production environment settings
    'production' => [
        // Template caching does not play nice with Blitz caching, disable it
        'enableTemplateCaching' => false,

CSRF tokens are also cached, so if you use {{ csrfInput() }} in your template, replace it with {{ craft.blitz.csrfInput() }}, this will add a Javascript snippet to the page that will dynamically add the correct CSRF value into the form.


We use Laravel Forge to provision and manage our servers, if you're not familiar with Nginx configuration, below is a snippet that will work on a standard Laravel Forge provisioned server.

If you use Apache or another setup for NGINX, check out the server rewrite documentation and find the configuration that is relevant to you and your hosting environment.

Laravel Forge Nginx Config
# Change from this
location / {
    try_files $uri $uri/ /index.php?$query_string;

# To this
location / {
    try_files /cache/blitz/$http_host/$uri/$args/index.html $uri $uri/ /index.php?$query_string;


I've successfully managed to reduce the TTFB (Time to first byte) from 600-900ms to ~25ms on a $5 droplet by using this plugin and setup, really amazing results in my opinion..

This is now a default plugin on all our sites.