Caching

New in 0.13.27

Generating an OpenAPI document analyzes your application’s routes, controllers, request validation, and response types — this takes time. Cache the generated document so Scramble does not analyze your code on every request. This is especially useful when serving documentation in staging or production.

Cache and clear the cache

Run scramble:cache to cache the OpenAPI document:

php artisan scramble:cache

When a cached document is available, both the documentation UI and JSON specification route use it instead of generating the specification again.

Clear the cache:

php artisan scramble:clear

Both commands handle every registered API by default. Target one API with --api:

php artisan scramble:cache --api=internal
php artisan scramble:clear --api=internal

Configure the cache

Set a cache key and Laravel cache store in config/scramble.php:

'cache' => [
'key' => 'scramble.openapi',
'store' => 'file', // or redis, database, and so on
],
Scramble PRO
Comprehensive API documentation generation for Spatie’s Laravel Data, Laravel Query Builder, and other packages.