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| Driver | Purge by tag | Credentials |
|---|---|---|
cloudflare | yes | CLOUDFLARE_ZONE_ID, CLOUDFLARE_API_TOKEN |
fastly | yes | FASTLY_SERVICE_ID, FASTLY_API_TOKEN |
bunny | through the tag registry | BUNNY_PULL_ZONE_ID, BUNNY_API_KEY |
cloudfront | through the tag registry | CLOUDFRONT_DISTRIBUTION_ID, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY |
varnish | yes | VARNISH_HOSTS |
nginx | through the tag registry | NGINX_CACHE_HOSTS |
multi | see below | each 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=databaseMulti
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.