Skip to content

Statamic Guide

Statamic is a powerful flat file CMS that’s perfect for the Webslice Serverless platform, we even use it for our own website! While Statamic will work out of the box, with some minor configuration, you can achieve excellent performance and keep costs low.

This guide will walk you through our recommendations, but it does assume you have a working website already. If you’re starting fresh, check out the official Statamic documentation to get your site set up locally first.

Key Concepts

  • The best performance on any hosting platform will come from static caching. Using Statamic’s static caching is strongly recommended, and will provide an excellent combination of performance and price. If you can use the full Static Site Generator, you’ll get even better results.
  • Git deploys support two deploy strategies: versioned (default) deploys are atomic and create a fresh copy each time, while live uses incremental syncing where untracked files persist between deploys.
  • We recommend using /mnt/data/website/shared for files you want to persist between deploys, such as uploads, image cache, logs, form submissions and more. This especially important when using versioned deploys.
  • Webslice Serverless is dynamic in nature, so if you want to use the Statamic Control Panel to make a quick edit to a live website you can. But remember, if you’re using versioned deploys, they are atomic, so you should also push the change to git locally so it’s not lost on the next deploy.
  • Webslice Serverless utilizes NFS (Network File System) storage, with our custom caching layer over the top. This makes makes it fast, but some tasks, such as locking files or writing to SQLite can impact performance.

If you want to configure your site by hand, rather than using our handy Webslice Provider, we can walk you through our recommended changes, based on our own experience running Statamic for our very own website.

Static Caching Setup

Statamic’s static caching is your best friend on a serverless platform. It pre-generates HTML files for your pages, which means:

  • Lightning-fast page loads
  • Minimal PHP execution
  • Lower costs (fewer invocations)
  • Better performance under traffic spikes

First, enable static caching in your config/statamic/static_caching.php:

config/statamic/static_caching.php
return [
'strategy' => env('STATAMIC_STATIC_CACHING_STRATEGY', half),
'strategies' => [
'half' => [
'driver' => 'application',
'expiry' => null,
],
'full' => [
'driver' => 'file',
'path' => public_path('static'),
'lock_hold_length' => 0,
'warm_concurrency' => 6,
],
],
];

The key settings here are:

  • strategy prepared with an environment variable which we will set to 'full' for maximum caching
  • driver set to 'file' which works well on serverless
  • warm_concurrency at 8 for efficient cache warming

Environment Variables

In the Webslice Console we recommend adding the below to the Env Vars section alongside your other variables:

Terminal window
STATAMIC_STATIC_CACHING_STRATEGY=full
STATAMIC_STACHE_WATCHER=false
APP_ENV=production
APP_DEBUG=false

These settings optimize Statamic for serverless deployments by enabling full static caching and disabling unnecessary tasks/workloads.

Persistent Storage Configuration

You may have some data that you don’t store in your git repository (or local site copy) that you do want to ensure persists between deploys. For those files they will need storing in the persistent /mnt/data/website/shared directory:

  • /mnt/data/website/shared - forms/ Form submissions - glide-cache/ Image manipulation cache - logs/ Application logs

To make these directories accessible to your Statamic application, you’ll create symlinks from your application to the shared directory. The best way to do this is in a deployment script.

Create a .webslice/build.sh file in your repository:

.webslice/build.sh
#!/bin/bash
# Create shared directories if they don't exist
mkdir -p /mnt/data/website/shared/forms
mkdir -p /mnt/data/website/shared/glide-cache
mkdir -p /mnt/data/website/shared/logs
# Remove existing directories/links from the build
rm -rf storage/app/forms
rm -rf storage/app/glide
rm -rf storage/logs
# Create symlinks to persistent storage
ln -sf /mnt/data/website/shared/forms storage/app/forms
ln -sf /mnt/data/website/shared/glide-cache storage/app/glide
ln -sf /mnt/data/website/shared/logs storage/logs
echo "✓ Symlinks created successfully"

Make the script executable:

Terminal window
chmod +x .webslice/build.sh

This script runs before the deployment goes live and ensures your persistent data is properly linked.

Cache Warming for Peak Performance

Cache warming is the process of pre-generating your static cache files. This is crucial because we want as many pages as possible to have their cache generated before a visitor hits the page:

The Release Script

Create a .webslice/release.sh file to warm your cache after each deployment:

.webslice/release.sh
#!/bin/bash
echo "Starting cache warming..."
# Clear any existing cache to ensure fresh generation
php artisan cache:clear
php artisan statamic:stache:clear
php artisan statamic:static:clear
# Warm the static cache
php artisan statamic:static:warm
echo "✓ Release complete"

Make it executable:

Terminal window
chmod +x .webslice/release.sh

This script runs after your deployment goes live.

Forms and Submissions

If you’re using Statamic’s built-in forms, you need to ensure submissions are stored in persistent storage. Since we symlinked storage/app/forms to /mnt/data/website/shared/forms in our deploy script, all form submissions will be preserved across deployments.

Image Manipulation (Glide)

Statamic uses Glide for on-the-fly image manipulation. To prevent regenerating these cached images on every deployment:

In your config/statamic/assets.php:

config/statamic/assets.php
return [
'image_manipulation' => [
'driver' => 'gd', // or 'imagick' if available
'cache' => true,
'cache_path' => storage_path('app/glide'),
'presets' => [
// Your image presets
],
],
];

The storage/app/glide directory is symlinked to /mnt/data/website/shared/glide-cache, so transformed images persist across deployments.

Deployment Checklist

When deploying your Statamic site to Webslice Serverless, follow these steps:

  1. Configure static caching in config/statamic/static_caching.php with the full strategy

  2. Create deployment script at .webslice/deploy.sh to set up symlinks to /mnt/data/website/shared

  3. Create release script at .webslice/release.sh to warm your static cache

  4. Make scripts executable with chmod +x .webslice/deploy.sh .webslice/release.sh

  5. Configure forms to store in persistent storage if using Statamic forms

  6. Set up Glide cache in persistent storage for image transformations

  7. Update .gitignore to exclude symlinked directories

  8. Deploy and monitor the first deployment to ensure cache warming completes