Should you use S3 or local cache for Docker caching in AWS CodeBuild? The bottom line: in most cases, local cache is the best choice. This article shows the concrete break-even points.
TL;DR (Conclusion)
Condition
Recommendation
Reason
Building twice a week or more
Local
S3 transfer costs $5-$30/month
Build host changes every time
S3
Local cache is ineffective
Building once a week or less
Either works
Cost difference is under $1/month
Two Caching Methods
Local Cache
1 2 3 4
cache { type = "LOCAL" modes = ["LOCAL_DOCKER_LAYER_CACHE"] }
Cost: Free
Constraints: Only effective on the same build host, requires privileged mode
Use case: CI/CD environments that build frequently
S3 Cache
1 2 3 4
cache { type = "S3" location = "my-bucket/cache" }
Cost: Storage $0.023/GB/month + transfer $0.09/GB
Advantage: Can be shared across all build hosts
Use case: Environments where the build host changes frequently