How to Choose Between Tag-Based and Time-Based Caching in Drupal Views
Under the Advanced > Caching section of every Drupal View, site builders face three choices: Tag based, Time based, or None. Most teams leave the default Tag based setting untouched—which is usually right—while others switch to Time based or None the moment a listing looks stale or slow. Choosing the wrong plugin can either flood your database with repeated queries or keep showing outdated content longer than editors expect.
Editorial illustration: tag-based caching invalidates on entity saves, whereas time-based caching holds output for a configured TTL.
Summary
- Tag based (the Drupal default) caches View results and rendered output indefinitely until a relevant cache tag—such as
node_listornode_list:article—is invalidated when content is created, edited, or deleted. - Time based caches View results and rendered output for a fixed duration (max-age), which is helpful for heavy aggregations, random-order blocks, or feeds during high-frequency imports.
- As documented in Drupal core Views caching discussions, core’s time-based plugin still carries list cache tags on output unless configured/extended carefully, meaning content edits can still invalidate it early—it acts as a maximum age, not a guaranteed minimum age.
- Never set Views caching to None in production as a shortcut for debugging stale data; inspect cacheability headers instead.
How Tag-Based Views caching works
When a View uses Tag based caching, Drupal stores two cached layers:
- Query results: The entity IDs returned by the View’s database query.
- Rendered output: The HTML markup for the View display (including any exposed filters or pager variations tracked via cache contexts).
Drupal attaches list tags (such as node_list or bundle-specific node_list:article in modern Drupal) plus the View configuration tag (config:views.view.<view_id>). The moment an editor publishes a new article, Drupal invalidates the matching list tag, and the next visitor rebuilds the View cleanly.
For most news listings, staff directories, and product catalogs, Tag based is the best choice because updates appear immediately without arbitrary delays.
When Time-Based Views caching makes sense
Time based caching lets you specify separate durations for Query results and Rendered output. Consider switching a specific View display to Time based when:
- The View uses relative time formatting or date filters. As noted in Drupal issue #2498969 and the Views Cache Plugin for Dates project, a pure tag-based View showing “Published 2 hours ago” or “Upcoming events after now” will not automatically invalidate as clock time passes if nobody edits a node. A short time-based TTL (or date-aware cache plugin) keeps relative timestamps accurate.
- The View sorts randomly (
Global: Random) or displays rotating recommendations. Tag-based caching would freeze the exact same “random” item until someone edits a node. A 5- or 15-minute time-based TTL rotates the block periodically without hitting the database on every request. - Heavy aggregate queries or
Search APIviews run during frequent edits. Note that for Search API Views, Search API caching behavior distinguishes tag-based, time-based, and combined plugins—always verify your Search API version’s cache plugin behavior on staging.
Important caveat: Time-based caching is a max-age, not a min-age
One of the most common surprises in Drupal Views is expecting “Time based: 1 hour” to shield the database from all rebuilds for a full hour even while editors publish 50 nodes.
Because Drupal’s render cache attaches list tags alongside the time-based max-age, editing a node still invalidates the tag-dependent render cache before the hour is up. Time-based caching guarantees the View will not stay stale longer than your chosen duration (useful for relative “time ago” strings), rather than forcing it to ignore content saves. Also note that in some older Drupal 10.1.x builds, custom time-based durations in Views had a UI/export quirk when mixing custom and predefined values—always inspect your exported views.view.*.yml config after saving.
Step-by-step: Pick and verify the right Views cache setting
- Leave standard content Views on
Tag based. Check that your View uses bundle-specific filters where appropriate so saving apagenode does not needlessly invalidate anarticleView. - Use
Time basedselectively on relative-date or random-sort displays. Set a practical duration (such as 5 minutes for “time ago” widgets or 15 minutes for random spotlights) and inspect the exported YAML withdrush cexto confirm the lifespan integers saved cleanly. - Debug stale Views with HTTP headers, not
None. If a View looks stale after an edit, enable debug cacheability headers on staging and follow how to debug Drupal cache tags without clearing all caches rather than turning caching off. - Watch exposed filters and personalized views. Exposed filters vary by URL query parameters (
url.query_args), while user-specific views vary by user or role—review Drupal cache contexts for personalized output and Drupal cache troubleshooting if different users see the wrong cached rows.
Common mistakes
- Setting Caching to
Noneon production Views. Even on a moderately busy site, an uncached View with multiple entity relationships and taxonomy joins can spike database CPU under bot traffic. - Forgetting that Drupal’s Internal Page Cache caches anonymous pages separately. Even if a View uses
Time based: 1 minute, anonymous visitors may still hitpage_cacheor an upstream CDN unlessmax-agebubbles properly to the full page response and your CDN honors it. - Importing custom YAML edits without checking
drush cimdiffs. Always review View configuration diffs before deploying, following a disciplined Drupal config import checklist.
Why this matters
Views power the majority of lists, blocks, and landing pages on a typical Drupal site. Matching each View display’s cache plugin to how its data actually changes keeps database load predictable while ensuring editors see published updates on time.
My Take
Keep Tag based as your default for 90% of Drupal Views—it is one of Drupal’s best architectural features. Reach for Time based only when clock time itself changes what the View should show (like “2 hours ago” labels, upcoming event windows, or random picks), and never leave None enabled in production.
Conclusion
Use Tag based caching for standard entity-driven Drupal Views, reserve Time based caching for time-sensitive or random-sort displays, verify exported views.view.*.yml settings after editing, and inspect X-Drupal-Cache-Tags on staging whenever a View appears stale.