How to optimize CodeBuild performance with caching?
A developer has a continuous integration and continuous delivery (CI/CD) pipeline that uses AWS CodeArtifact and AWS CodeBuild. The build artifacts are between 0.5 GB and 1.5 GB in size. The builds happen frequently and retrieve many dependencies from CodeArtifact each time. The builds have been slow because of the time it takes to transfer dependencies. The developer needs to improve build performance by reducing the number of dependencies that are retrieved for each build. Which solution will meet this requirement?
Community Votes
100% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.
Community Insight
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.
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.
Community Discussion (4 comments)
Comments & Corrections
No comments yet — spotted an error or have a note? Share it below.
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 inbuildspec.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
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.
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