Skip to content
tezvyn:

Top 30 Caching Interview Questions and Answers

30 multiple-choice questions on Caching, drawn from 30 bites out of the 59 tagged Caching on Tezvyn. Answer them here or read straight down. Every question carries the correct option, why it is correct, and a link to the bite it came from.

30 questions. Pick an answer, or open “Show the answer” to read it.

Answers are graded in your browser. Nothing is saved, and no XP or streak is earned here. The app keeps score.

  1. Question 1 of 30

    Which statement accurately describes the primary trade-off when using a materialized view?

    Show the answer

    Answer: b · It sacrifices data freshness to achieve faster query execution.

    The card explicitly states that a materialized view involves a "direct tradeoff: speed for freshness." It pre-computes and stores query results for faster access, but this means the data can be stale. Option A is incorrect because materialized views increase storage by storing a physical copy of the data. Option C is incorrect as they primarily improve read performance, not write performance. Option D is incorrect because materialized views introduce data staleness, which is the opposite of real-time consistency.

    Read the full bite: Materialized Views: Pre-computing Slow Queries

  2. Question 2 of 30

    Which design best supports millions of concurrent social proof notifications without overloading the database?

    Show the answer

    Answer: a · Fire-and-forget beacons, stream processor with windowed aggregation, and hot cache with TTL

    The correct pipeline decouples producers from consumers via a stream processor and shields the database with a hot cache, making approximate counts scalable. Synchronous SQL updates per page view turn the counter into a hot key that collapses under concurrent load, so option B fails at scale.

    Read the full bite: How would you design a near real-time social proof notification system?

  3. Question 3 of 30

    How should a high-scale headless CMS prevent thundering herds on a viral article while ensuring newly published edits appear immediately?

    Show the answer

    Answer: a · Use request coalescing at the origin and actively purge CDN edge nodes via surrogate-key invalidation events on every publish

    Request coalescing collapses concurrent origin fetches for the same key to prevent thundering herds, while surrogate-key invalidation actively clears edge caches on publish instead of waiting for TTL. Option C is tempting because stale-while-revalidate is a valid resilience tactic, but without explicit invalidation it cannot guarantee that a newly published edit appears immediately.

    Read the full bite: Design a highly scalable headless CMS architecture

  4. Question 4 of 30

    What is the most reliable way to ensure users receive an updated CSS file without serving stale edge copies?

    Show the answer

    Answer: d · Use a content-hashed filename so the updated asset has a brand-new URL

    A content hash changes the URL on every update, so the edge treats it as new and never serves a stale copy. Global purges are slow and propagate unevenly, and a zero TTL defeats CDN caching entirely.

    Read the full bite: CDN caching for static and dynamic content

  5. Question 5 of 30

    A pull-through cache reduces cross-region pull cost primarily because:

    Show the answer

    Answer: d · After the first pull, subsequent in-region pulls are served locally instead of crossing regions

    The cache fetches once from upstream then serves the region locally, cutting egress and latency. It does not change compression (A), auth (C), or architecture (B).

    Read the full bite: Reducing cross-region image pull costs

  6. Question 6 of 30

    In FastAPI, a database-querying dependency is injected into both a path operation and a sub-dependency. By default, what happens during a single request?

    Show the answer

    Answer: c · The dependency runs once and the cached value is reused only within that request's dependency tree

    FastAPI defaults to use_cache=True, so it executes the dependency once per request and reuses that cached value throughout the same request's dependency tree. Option A is a common misconception: FastAPI does not independently resolve every Depends() declaration; it avoids redundant work by caching within the request lifecycle.

    Read the full bite: How does FastAPI cache dependencies within a single request?

  7. Question 7 of 30

    Which type of content should generally NOT be served through a Content Delivery Network (CDN)?

    Show the answer

    Answer: b · A user's unique shopping cart details

    The card explicitly states that highly dynamic or personalized content, such as a user's shopping cart, should not be cached on a CDN to prevent data leaks. Static assets like images, JavaScript, and pre-recorded videos are ideal for CDN delivery.

    Read the full bite: Content Delivery Network (CDN): Serving Content from the Edge

  8. Question 8 of 30

    On a cache dashboard, which metric most directly warns that the cache is becoming ineffective for callers?

    Show the answer

    Answer: b · Falling cache hit ratio over time

    A declining hit ratio means more requests miss the cache and fall through to the backend, directly degrading effectiveness. Cumulative command totals and uptime do not indicate cache health on their own.

    Read the full bite: Designing a cache health dashboard

  9. Question 9 of 30

    Which strategy best balances cache efficiency and personalization for SSR pages at scale?

    Show the answer

    Answer: d · Use segment-level cache keys with short TTLs and stale-while-revalidate, resolving variants at the edge

    Segment-level keys prevent cache explosion while short TTLs with stale-while-revalidate shield the origin from overload; per-user caching seems precise but destroys hit rates and explodes storage costs.

    Read the full bite: Caching and performance challenges in SSR with personalized copy

  10. Question 10 of 30

    In a cache-aside setup, what happens on a cache miss for a requested key?

    Show the answer

    Answer: a · The app reads from the database, stores the result in the cache, then returns it

    Cache-aside puts the application in control: on a miss it reads the DB, populates the cache, and returns the value. The cache itself does not fetch from the DB, which is the write-through or read-through misconception.

    Read the full bite: How does caching reduce database load?

  11. Question 11 of 30

    When designing a low-latency entitlement system, how should the hot path handle plan validation and quota checks?

    Show the answer

    Answer: c · Issue signed edge tokens for plan validation and stream quota usage to an async pipeline

    The correct approach separates the user-facing hot path from background policy work by validating signed edge tokens locally and streaming quota events asynchronously, keeping latency under five milliseconds. A synchronous database lookup per request is a common red flag because it couples the hot path to a remote dependency and creates a scaling bottleneck.

    Read the full bite: Propose a scalable entitlement architecture for complex rules

  12. Question 12 of 30

    Why does renaming a user via one mutation instantly update every screen showing that user in Apollo's normalized cache?

    Show the answer

    Answer: c · The entity is stored once by its cache id, so all queries reference the same record

    Normalization stores each entity a single time keyed by typename and id, so updating it propagates to every query referencing it. Apollo does not auto-refetch all queries, poll, or remount components for this, so those options are wrong.

    Read the full bite: Apollo's normalized cache

  13. Question 13 of 30

    In a tiered entitlement cache, how should temporary grants be modeled to avoid degrading cache hit rates?

    Show the answer

    Answer: d · Append them to an event-sourced log and cache with a TTL matching their explicit expiration

    Temporary grants are high-churn, time-bound state that pollutes the cache if handled like static features; event-sourced append-only logs with precise TTLs keep them off the hot path without overwhelming the database. Querying the primary store directly for every check would recreate the exact bottleneck a multi-tier cache is designed to prevent.

    Read the full bite: Design a highly available entitlements service with caching

  14. Question 14 of 30

    Which scenario highlights a fundamental limitation of key-value stores?

    Show the answer

    Answer: c · Finding all products in a catalog that are currently on sale.

    Key-value stores are designed for direct key lookups and cannot efficiently query data based on its attributes or values, as explicitly stated in the card. Options A, B, and D describe common and appropriate use cases for key-value stores, leveraging their strength for fast, key-based access.

    Read the full bite: Key-Value Store: The Simplest Database Model

  15. Question 15 of 30

    Which approach best handles a news feed requiring fast launch, offline survival, and minimal bandwidth usage?

    Show the answer

    Answer: a · Stale-while-revalidate with Hive persistence and ETag conditional requests

    Stale-while-revalidate renders the feed instantly from Hive while refreshing in the background, and ETag avoids redundant downloads via 304 responses. Option D is wrong because an in-memory LRU cache alone is lost on app termination, providing no offline resilience despite the cache-first policy.

    Read the full bite: Implement an API caching layer with offline support and storage trade-offs

  16. Question 16 of 30

    When configuring a server-state library to share cache between a list and detail view, which strategy best avoids refetching on back-navigation while keeping data updated?

    Show the answer

    Answer: c · Use nested query keys so the detail pulls from the list cache, set staleTime to a few minutes, and keep background refetch enabled.

    Nested query keys let the detail view reuse list cache as placeholder data, and a non-zero staleTime prevents refetching on back-navigation while background refetching preserves freshness. Using a general client store like Redux is a red flag because it lacks built-in deduplication, TTL, and normalization for server state.

    Read the full bite: How would you cache data between a list and detail view?

  17. Question 17 of 30

    In an ISR-enabled Next.js application, what is the immediate user experience when accessing a page whose cached content has expired?

    Show the answer

    Answer: a · The user is served the stale, cached page while a new version is generated in the background.

    The card states that if a page is past its 'best before' date, the user still sees the old content instantly, but their visit triggers a background process to create a new version. This 'stale-while-revalidate' approach means the user doesn't wait, making option C incorrect.

    Read the full bite: ISR: Static Speed with Dynamic Freshness

  18. Question 18 of 30

    What is the best long-term resolution for repeatedly paging to clear a cache after deploys?

    Show the answer

    Answer: a · Automate the clear in the deploy pipeline and address why the deploy invalidates the cache

    Eliminating toil means automating the action and, better still, removing the need via versioned cache keys. A runbook still requires a human, and resizing or rotating on-call does not address the recurring trigger.

    Read the full bite: Automating a recurring manual cache clear

  19. Question 19 of 30

    What is the primary reason to implement a managed in-memory data store in an application architecture?

    Show the answer

    Answer: c · To accelerate data retrieval for frequently accessed information by leveraging RAM-based storage.

    The card highlights that in-memory stores exist to provide a "fast, intermediate data layer" and "microsecond latency" for frequently accessed data by storing it in RAM. Option A describes features of a traditional database, which the card explicitly advises against using an in-memory store for, as it's not designed for strong transactional guarantees or permanent persistence.

    Read the full bite: Managed In-Memory Data Store: Speed Without the Sysadmin

  20. Question 20 of 30

    In which scenario would semantic caching be most problematic or risky to implement?

    Show the answer

    Answer: d · A legal analysis tool where precise wording and nuance are critical for correct output.

    The card states to "Avoid relying on semantic caching for tasks where nuance is critical and small changes in the prompt demand a different answer, such as in legal analysis." Option A describes a scenario best suited for prefix caching, not a problem for semantic caching.

    Read the full bite: LLM Inference Caching: Pay for Computation Once

  21. Question 21 of 30

    For which scenario is TanStack Query the most appropriate state management tool?

    Show the answer

    Answer: b · Caching and synchronizing a list of items from a remote database.

    TanStack Query is designed for asynchronous server state, such as fetching and caching data from a remote API. The other options describe synchronous client-side UI state, which is best managed with standard client-side state tools like useState.

    Read the full bite: TanStack Query: Managing Server State, Not Client State

  22. Question 22 of 30

    Which scenario would be an inappropriate use case for RTK Query, according to its design principles?

    Show the answer

    Answer: d · Storing the current user's selected language preference for the UI.

    RTK Query is designed for managing asynchronous server state, not global client-side UI state. Storing a user's selected language preference is an example of client-side UI state, for which a regular Redux slice created with createSlice is the appropriate tool. The other options describe core functionalities and appropriate use cases for RTK Query, such as fetching, caching, and automatic refetching of server data.

    Read the full bite: RTK Query: Your Redux Data Fetching Layer

  23. Question 23 of 30

    What is the correct way to run a database query only once when both a layout and its nested pages need the same data in the App Router?

    Show the answer

    Answer: c · Wrap the query in React cache and call it from both the layout and nested Server Components

    React cache memoizes the query for the duration of the request, so invoking it in both the layout and nested pages deduplicates the database call. Option A is tempting but incorrect because App Router layouts cannot pass custom props to their child pages.

    Read the full bite: Recommended App Router pattern to fetch shared data once for child routes

  24. Question 24 of 30

    What is the primary outcome when a server is removed from a distributed system employing consistent hashing?

    Show the answer

    Answer: b · Only the data keys that were previously assigned to the removed server are remapped.

    Consistent hashing ensures that when a server is removed, only the keys it previously owned are reassigned to its clockwise neighbor on the ring, localizing the impact. Option A describes the problem consistent hashing aims to solve, which is the mass remapping caused by simpler modulo-based hashing.

    Read the full bite: Consistent Hashing: Resizing Distributed Systems Gracefully

  25. Question 25 of 30

    When architecting a Next.js App Router product page, which approach best aligns with the recommended hybrid data strategy?

    Show the answer

    Answer: a · Fetch review summaries in a Server Component and handle inventory checks with a client fetching library

    Review summaries are stable and SEO-critical, so they belong in a Server Component, whereas inventory checks need optimistic updates and background refetching best handled by a client library. Option C misapplies server deduplication to interactive data that requires instant mutation feedback.

    Read the full bite: Server Component fetch vs. client-side SWR or React Query

  26. Question 26 of 30

    In a news PWA, a user opens a previously visited article while offline. How does the Service Worker make this possible?

    Show the answer

    Answer: c · It intercepts the article fetch request and returns the matching cached response.

    The Service Worker acts as a programmable network proxy that intercepts fetch requests and can decide to return cached assets when the network is unavailable. Option D is a common misconception because Service Workers run in a separate worker context and cannot manipulate the DOM directly.

    Read the full bite: What is a Service Worker's role and key PWA capability?

  27. Question 27 of 30

    Which configuration correctly implements ISR for a semi-static page inside a Next.js App Router Server Component?

    Show the answer

    Answer: c · Pass next: { revalidate: 60 } to fetch or export const revalidate = 60 from the page

    Option C is correct because App Router Server Components use either the fetch revalidate option or a segment-level revalidate export. Option A is wrong because Server Components cannot use useEffect, which is a client-side hook.

    Read the full bite: Describe an ideal ISR scenario and configure it in a Server Component

  28. Question 28 of 30

    When building a news PWA, which asset should use a Cache First strategy?

    Show the answer

    Answer: c · The compiled app.js bundle with a content hash in its filename

    Cache First is ideal for immutable hashed bundles because they never change and should load instantly from the Cache API. Option B describes a Network First scenario, since headlines require the latest content but still need offline fallback.

    Read the full bite: Explain Network First vs Cache First caching and when to use each

  29. Question 29 of 30

    In the cache-aside pattern, what must the application do on a write to avoid serving stale data?

    Show the answer

    Answer: d · Update or invalidate the corresponding cache key after writing to the database

    Cache-aside puts invalidation in the application's hands, so after a write it must update or delete the affected key. The cache does not observe database changes on its own.

    Read the full bite: Cache-aside pattern with Redis and RDS

  30. Question 30 of 30

    For on-demand ISR triggered by a CMS webhook in Next.js App Router, which implementation is architecturally correct?

    Show the answer

    Answer: d · Create a POST Route Handler that validates a webhook secret, calls revalidatePath, and returns; the next request triggers background regeneration while briefly serving stale content.

    A Route Handler is the proper place to receive webhooks because it can securely validate secrets and mutate shared cache state outside of React's render cycle. Calling revalidatePath inside a Server Component body is illegal because Server Components must remain pure and idempotent during render.

    Read the full bite: How do you implement on-demand revalidation from a CMS webhook?

Could you explain these out loud?

That is what an interview actually tests. Tezvyn gives you questions like these with what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon