How to optimize CodeBuild performance with caching?
Short answer
C Specify a local cache in CodeBuild. Add the cache folder path to the buildspec.yaml file for the build project.
Question
Key Takeaways
The question tests knowledge of CodeBuild caching modes, specifically distinguishing between S3 and local caches and the correct buildspec configuration (paths vs. repository names).
To improve AWS CodeBuild performance when handling large dependencies from AWS CodeArtifact, developers should implement a local cache. This reduces network transfer time by storing dependencies on the build host for subsequent builds.
Common mistake: Selecting Option B is a common error because while it correctly identifies 'local cache,' it incorrectly suggests adding the repository name to the buildspec instead of the specific cache folder paths.
Expert Analysis
Why the Answer Is Correct
Local caching in CodeBuild stores dependencies on the build environment's storage, which is significantly faster than downloading them over the network from CodeArtifact for every build. By specifying the cache folder path in buildspec.yaml (e.g., /root/.m2 or node_modules), CodeBuild preserves these directories between builds, minimizing download times for the 0.5 GB to 1.5 GB artifacts.
Why the Other Options Are Wrong
Option A suggests an S3 cache, which incurs network latency for uploading and downloading cache archives, making it slower than a local cache for frequent builds. Option B is incorrect because you configure cache paths in the buildspec, not the CodeArtifact repository name; the repository is used in the build commands, not the cache definition. Option D is invalid because buildspec files are sourced from CodeCommit, S3, or GitHub, not CodeArtifact, and this approach does not address dependency caching.
Community Comment Notes
The community strongly supports Option C (90 votes), emphasizing that local caching reduces retrieval time. One comment (Comment [4]) incorrectly argues for Option B, claiming Option C lacks CodeArtifact integration, but caching works based on file paths regardless of the package source. Another comment (Comment [3]) provides a practical example of configuring cache paths for pip dependencies.
Official Reference
- https://docs.aws.amazon.com/codebuild/latest/userguide/build-caching.html
- https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html#build-spec-ref-syntax
These links open the official vendor documentation in a new tab.
Exam Strategy
When asked to improve build speed related to dependencies, immediately look for 'Local Cache' as the preferred solution over S3 cache due to lower latency, provided the build environment supports it.
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 4 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 4
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All DVA-C02 Questions
Access 100 questions with complete answers and detailed explanations.
View Full DVA-C02 Practice Test →
date- echo Compiling the Python code... - python setup.py build cache: paths: - '/root/.cache/pip/*/' # dependencies cache