Skip to content

CDN drivers ​

Pick the driver of the cache in front of your app:

ini
INERTIA_STATIC_CDN=cloudflare   # cloudflare | fastly | bunny | cloudfront | varnish | nginx | multi | null
DriverPurge by tagCredentials
cloudflareyesCLOUDFLARE_ZONE_ID, CLOUDFLARE_API_TOKEN
fastlyyesFASTLY_SERVICE_ID, FASTLY_API_TOKEN
bunnythrough the tag registryBUNNY_PULL_ZONE_ID, BUNNY_API_KEY
cloudfrontthrough the tag registryCLOUDFRONT_DISTRIBUTION_ID, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
varnishyesVARNISH_HOSTS
nginxthrough the tag registryNGINX_CACHE_HOSTS
multisee beloweach driver's
null—— (sends cache headers, never purges)

Credentials are only needed to purge. Without them, pages are cached and expire by time: headers-only mode.

Drivers marked "through the tag registry" need a tag registry to purge by tag:

ini
INERTIA_STATIC_REGISTRY=database

Multi ​

Several caches at once, e.g. Varnish in front of the app and Cloudflare at the edge:

php
// config/inertia-static.php
'drivers' => [
    'multi' => ['driver' => 'multi', 'drivers' => ['varnish', 'cloudflare']],
],

Every purge goes to every cache. If one of them has no tag purge, enable the tag registry.

Custom drivers ​

php
use Fydellys\InertiaStatic\Facades\StaticCache;

StaticCache::extend('my-cdn', fn ($app, array $config) => new MyCdnDriver(
    $app->make(\Illuminate\Http\Client\Factory::class),
    $config,
));
php
// config/inertia-static.php
'drivers' => [
    'my-cdn' => ['driver' => 'my-cdn', 'token' => env('MY_CDN_TOKEN')],
],

MyCdnDriver extends Fydellys\InertiaStatic\Cdn\Driver and implements the cache headers and the purge methods your CDN supports.

Released under the MIT License.