How do I invalidate the cache for Spinup static website?

Problem

I need to invalidate the cache for a static website in Spinup

Solution

Spinup static websites are hosted in Amazon S3 and fronted by Amazon's CDN, Cloudfront.  In addition to allowing for HTTPS connections, cloudfront caches static content served from S3 websites.  Spinup provides two ways for users to invalidate the cache for their website.  All cache invalidation requests may take up to 5 minutes to propagate through Amazon's network.

Invalidating via the UI

Spinup allows users to create a cache invalidation request via the Spinup UI.  This is the simplest way to invalidate the cache for your website and will invalidate all objects in the cache.

Simply navigate to your website resource within the Spinup UI and click the "Clear Cache" button in the Control Panel.  This will create a cache invalidation request which may take up to 5 minutes to complete.

Invalidating via the AWS CLI

Some Spinup users would like to automatically invalidate their cache via a pipeline when updating their static site.  This is most simply accomplished via the AWS CLI, but any Amazon Cloudfront client should work.  This process will create an invalidation request that may take up to 5 minutes to complete.

By default, the access keys you generated to upload/delete content to your website have also been granted access to create cache invalidation requests.

In addition, you will also need the ID of the Cloudfront distribution associated with your static site.

Then you can use the AWS CLI to create an invalidation request.  You also have fine grained control over the assets you wish to invalidate.

For example:

Invalidate all objects
aws cloudfront create-invalidation --distribution-id E2V6DOPOAYCPFK --paths '/*'
Invalidate just one file
aws cloudfront create-invalidation --distribution-id E2V6DOPOAYCPFK --paths '/images/logo.jpg'
List your invalidations and their status
aws cloudfront list-invalidations --distribution-id E2V6DOPOAYCPFK