Courseiva
Question 866 of 964
Building and testing applicationshardMultiple ChoiceObjective-mapped

PCD Building and testing applications Practice Question

A developer is designing a CI/CD pipeline for a Node.js application hosted on Cloud Run using Cloud Build. The pipeline should run unit tests, build the container, push to Artifact Registry, and deploy to Cloud Run. The developer wants to minimize build time by caching dependencies. What is the recommended approach?

⚠ Common exam trap

The PCD exam often tests the misconception that committing `node_modules` or using custom base images are efficient caching strategies, but the correct approach is to use Cloud Build's native persistent volume caching, which is purpose-built for this scenario.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Use Cloud Build's built-in caching with a persistent volume to store node_modules between builds.

Cloud Build supports built-in caching via persistent volumes (e.g., `/cache` or `/workspace`) that can store `node_modules` across builds. By configuring a cache volume in the `cloudbuild.yaml` and using `npm ci --prefer-offline`, the pipeline avoids re-downloading dependencies on every run, significantly reducing build time for Node.js applications on Cloud Run.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Run npm install locally and commit the node_modules folder to the repository for faster builds.

    Why it's wrong here

    Committing node_modules is not best practice and increases repository size.

  • Use Cloud Build's step-level caching by copying the node_modules from a previous build step.

    Why it's wrong here

    Step-level caching does not persist across separate builds.

  • Create a custom base image that includes all dependencies and reference it in the Dockerfile.

    Why it's wrong here

    This approach works but is less flexible and requires maintaining the base image.

  • Use Cloud Build's built-in caching with a persistent volume to store node_modules between builds.

    Why this is correct

    Cloud Build's volume caching allows dependency caching across builds.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 11, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

This PCD practice question is part of Courseiva's free Google Cloud certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCD exam.