Smart Caching Decisions Quiz: When and What to Cache Quiz

  1. Identifying Cacheable Data

    Which type of data is generally the best candidate for caching to reduce database load?

    1. Frequently-read, rarely-changing data
    2. Rapidly-mutating session tokens
    3. Temporary user uploads
    4. Real-time sensor readings
    5. Large image files stored in the file system
  2. Choosing Cache Granularity

    Suppose your web application often displays product details. Which caching strategy is best if product data changes infrequently, but associated reviews update constantly?

    1. Cache product details separately from reviews
    2. Cache both product details and reviews together
    3. Cache only the reviews
    4. Do not cache anything
    5. Cache the user's search queries instead
  3. Recognizing What NOT to Cache

    Which one of these should typically NOT be cached to avoid serving outdated information?

    1. Highly dynamic, per-user financial transactions
    2. Popular static blog articles
    3. Data pulled from a rarely-updated configuration file
    4. Public product catalog pages
    5. Frequently-accessed error messages
  4. Understanding Cache Invalidation

    If a cached value is updated in the database, what is the recommended action for the cache?

    1. Invalidate or update the cached value immediately
    2. Wait until the cache expires naturally
    3. Add a new cache entry alongside the old one
    4. Ignore the change; caching takes priority
    5. Clear all cached data unrelated to the change
  5. Cache Key Granularity

    When caching user-specific dashboard data, which cache key strategy best avoids incorrect data being shown to the wrong user?

    1. Include the user's unique ID in the cache key
    2. Use a global cache key for all users
    3. Use the URL path as the cache key
    4. Base the cache key on the current date
    5. Ignore cache keys to simplify the design
  6. Deciding What Computations to Cache

    You have a function that performs an expensive aggregation over millions of rows. The aggregation result is requested often and is updated only once a day. How should you handle caching?

    1. Cache the aggregation result and invalidate it daily
    2. Recompute the aggregation for every request
    3. Do not cache and serve stale results
    4. Cache only for premium users
    5. Cache the function input parameters instead
  7. Cache Invalidation Typo Trap

    What issue might you face if you forget to invalidiate a cache entry after updating data?

    1. Stale data being served to users
    2. Increased database accuracy
    3. Improved real-time updates
    4. Faster cache build times
    5. Accidental removal of valid cache
  8. Evaluating Computation Cost

    When deciding whether to cache a computation, which is the most important factor?

    1. The cost (CPU/memory/time) of recomputing the value
    2. The number of lines in the function
    3. How many developers worked on the feature
    4. The name of the cache server
    5. The color scheme of your application
  9. Scenario: Cached User Profile

    You cache user profile pages. Which event should trigger a cache invalidation for a user's profile?

    1. When that user updates their profile information
    2. When any user logs out
    3. On midnight every night
    4. When the application deploys
    5. During every API call
  10. Cache Duration Considerations

    If you have data that changes infrequently, which cache strategy is generally best?

    1. Set a long cache expiration time
    2. Use no cache at all
    3. Set a very short cache duration
    4. Purge the cache every minute
    5. Only cache the data after it has been requested 100 times