Acquia Developer (D10) study materials
Acquia Developer (D10) study resources

Editorial site with a caching and stale-content complaint

Acquia Developer (D10) · Put your knowledge to work in context.

All case studies

Editorial site with a caching and stale-content complaint

A Drupal 10 site runs on Acquia Cloud with Varnish in front of three web nodes. Editors report that a promoted article's updated teaser on the home page still shows the old summary for about 10 minutes after saving, but the article's own detail page is correct immediately. The home page is a view of 12 promoted nodes rendered inside a custom block with a max-age of 3600 set by the theme's preprocess. A developer proposes clearing Varnish on every node save. Traffic is 40,000 page views/day with a 70% cache hit rate target.

1. Diagnose why the home page is stale while the node page is fresh, and propose a cacheability fix that does not rely on purging on every save.

Read the worked answer

The node detail page is fresh because entity access and rendering attach per-entity cache tags and contexts, and saving a node invalidates its own tag, which propagates to Varnish via Acquia's purge integration. The home page view should also bubble up the node:ID tags of the rendered rows, so the real culprit is the custom block or preprocess that sets a blanket max-age of 3600. An explicit max-age does not remove cache tags, but if the block is rendered with #cache['max-age'] = 3600 and the tags are not bubbled, or if the view is embedded without #pre_render bubbling, invalidation never reaches the page. The fix: let cache tags bubble ($build['#cache']['tags'] from the view), avoid hardcoding max-age on the block, and confirm page_cache and dynamic page cache are enabled with response.gin/page policies intact. Purging Varnish on every save is a symptom fix that will crush the hit-rate target; tag-based invalidation is the correct mechanism.

2. How would you verify the fix before it ships, and what metric would you watch after deploy?

Read the worked answer

Before shipping: save a promoted node, then request the home page through the full stack (not just the origin) and check the X-Drupal-Cache-Tags / X-Cache headers to confirm the node:ID tag is present and that the response is a HIT after the second request. Use drush cache:tag-invalidate node:ID or simply resave and curl twice. Also inspect the block's rendered array with a debugger or drupal_set_message-free var dump in a dev environment to confirm tags are bubbled. After deploy: watch the Varnish hit ratio (should stay near 70%) and the purge volume in Acquia Cloud logs. A spike in purges per minute means tags are still being over-broadcast (e.g., a node_list tag on every page).