Configuration
All configuration can be set via the published config file or environment variables.
Header Names
Idempotency Key Header
The header clients use to send their idempotency key:
'main_header_name' => env('IDEMPOTENCY_MAIN_HEADER', 'Idempotency-Key'),
Replayed Response Header
The header added to responses that are served from cache:
'repeated_header_name' => env('IDEMPOTENCY_REPEATED_HEADER', 'Idempotent-Replayed'),
Expiration Time
How long cached responses are stored, in minutes. After this time, the idempotency key can be reused:
'expiration_time' => env('IDEMPOTENCY_EXPIRATION_TIME', 360), // 6 hours
HTTP Methods
Which HTTP methods the middleware applies to. Requests using other methods are passed through without idempotency handling:
'http_methods' => ['POST', 'PUT', 'PATCH', 'DELETE'],
To limit it to only POST requests:
'http_methods' => ['POST'],
Environment Variables
You can configure everything via .env without publishing the config file:
IDEMPOTENCY_MAIN_HEADER=Idempotency-Key
IDEMPOTENCY_REPEATED_HEADER=Idempotent-Replayed
IDEMPOTENCY_EXPIRATION_TIME=360
Cache Driver
The middleware uses Laravel's default cache driver. To use a specific driver for idempotency, configure a dedicated cache store in config/cache.php and set it as default, or use a tagged cache approach in your application.
For production, a persistent cache driver like Redis or Memcached is recommended to ensure idempotency keys survive across deployments.