daynnnnn / statamic-cloudfront
Allows you to use cloudfront as a statamic cache strategy.
Installs: 1 907
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 2
Open Issues: 0
Requires
- aws/aws-sdk-php: ^3.0
- statamic/cms: ^5.0
Requires (Dev)
- laravel/pint: ^1.20
- phpstan/phpstan: ^0.12.89
README
Use cloudfront as a static cache driver.
Installation
From a standard Statamic V3 site, you can run:
composer require daynnnnn/statamic-cloudfront
Then you'll just need to add the cloudfront strategy to your static cache config:
'strategies' => [
...
'cloudfront' => [
'driver' => 'cloudfront',
'expiry' => null,
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION'),
'distribution' => env('CLOUDFRONT_DISTRIBUTION_ID'),
],
],
How it works
It's pretty simple; if the page should be cached, it sets the responses cache control header to cache for 30 days. Then if a page is updated, an invalidation request will be sent to cloudfront for that page.
Things to work on
- Add some tests.
- Try and remove
aws/aws-sdk-php
dependency.