CloudFront Caching
So I ran into something after my last post that was unexpected. After I ran the command, aws sync
, to upload the new post and changes I expected to see the changes not long after but this was not the case. Several hours later and the post still had not shown. I determined the issue was CloudFront because when accessing the bucket URL the changes were immediate and I could see all of the newly uploaded files.
My laptop, which was on a VPN noticed the changes after several hours but only partially in that the home page had a link to the new post, but the posts archive did not. Either way, this wouldn’t work with the website being served partially from cache, thus providing inconsistent and partial results depending on where you are.
The resolution to this issue was to change the CloudFront Distribution Behavior. Cache Based on Selected Request Headers should be changed from the default of None(improves caching) to All.
Once I made this change, I almost immediately saw the changes completely on all devices even while the Distribution was deploying. What this change does is effectively turn off caching and forward all requests directly to the origin (s3 bucket)