CloudFront Invalidation...a facepalm

Publii, the static site generator I use to edit this blog, had a new release and themes which I installed. After publishing a new post however something broke. I'm not claiming that the site is the pinnacle of web design and typography, but in my not so humble opinion, it does at least look decent. Not so after the update. Queue in a few hours of troubleshooting - dissecting CSS, purging content from the S3 bucket, trying different themes, etc. 

A few cups of coffee later, and one gigantic face-palm, it dawned on me that I had a CloudFront distribution caching content. As Publii pushed contents with the same name, overwriting files in the S3 bucket, CloudFront was still happily serving funky looking cached content. 

The two ways to prevent that from happening are to:

  • implement versioning, ex. instead of uploading image.jpg, upload image_v1.jpg
  • or, invalidate content (which is what I did). 

You can of course also simply opt to wait the default 24 hours which is the TTL of cached items.

The caveat with invalidation is that after 1000 object invalidations, it is going to cost you. 

Moral of the story - sometimes when troubleshooting you develop tunnel vision and miss glaringly obvious things. Need to step away from the keyboard and do something else. That and I am also an idiot :). 

 

Comments