Skip to content

Allows you to use cloudfront as a statamic cache strategy

License

Notifications You must be signed in to change notification settings

Daynnnnn/statamic-cloudfront

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Statamic Cloudfront

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.

About

Allows you to use cloudfront as a statamic cache strategy

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages