Auto-Refresh & Live Data

Turn any TableCrafter table into a live dashboard. Stale-While-Revalidate (SWR) caching serves cached data instantly while refreshing in the background, and the client-side Smart Auto-Refresh engine keeps visible tables current without disrupting the people reading them.

[tablecrafter]SWR CachingSmart PausingVisual IndicatorsHealth Monitor

Two layers of freshness

TableCrafter keeps data fresh through two complementary mechanisms. They are independent and can be used together.

ℹ️

SWR keeps the first paint fast and the cache warm. Auto-refresh keeps an already-rendered table updating live. For a true real-time dashboard you typically want both, which is the default behavior when you add auto_refresh="true".

Enabling auto-refresh

Add auto_refresh="true" to the [tablecrafter] shortcode. With no other settings, the table refreshes every 5 minutes, shows the refresh indicator, and displays a "last updated" timestamp.

# Minimal live table — refreshes every 5 minutes (default)
[tablecrafter source="https://api.example.com/data.json" auto_refresh="true"]

For a faster-moving source, set an explicit interval and turn on the countdown so visitors can see when the next update lands.

# Live dashboard — refresh every 30 seconds, with countdown
[tablecrafter source="https://api.example.com/live-data.json"
  auto_refresh="true"
  refresh_interval="30000"
  refresh_countdown="true"]

Auto-refresh attribute reference

All auto-refresh attributes are parsed by the [tablecrafter] shortcode and mirrored as data-* attributes the front-end engine reads. Intervals are expressed in milliseconds.

AttributeDefaultDescription
auto_refreshOptional falseMaster switch. When true, the browser-side refresh cycle starts after the table renders.
refresh_intervalOptional 300000Time between refreshes in milliseconds. 30000 = 30s, 300000 = 5min, 3600000 = 1hr.
refresh_indicatorOptional trueShows the visual control bar: spinning icon, status text, pause/resume button, and a manual "refresh now" button.
refresh_countdownOptional falseAdds a live countdown ("Next: 24s") to the indicator showing time until the next refresh.
refresh_last_updatedOptional trueShows a relative timestamp ("Updated 3m ago") so readers can judge data freshness.
⚠️

refresh_interval defaults to 300000 (five minutes) when set to 0 or an invalid value in the Gutenberg block. Auto-refresh also requires a fetchable source URL — if no data URL is available, the engine logs a warning and skips refreshing.

Smart interaction pausing

The defining feature of TableCrafter auto-refresh is that it gets out of the way. A background refresh that re-renders a table while someone is mid-scroll, mid-sort, or reading a filtered view is jarring, so the engine pauses automatically and resumes when the user steps away.

Smart pausing is enabled by default — there is no shortcode attribute to disable it, and you generally should not want to. It is what makes a 30-second refresh interval usable on a table people actually interact with.

Visual indicators and manual controls

When refresh_indicator="true" (the default), TableCrafter inserts a small status bar above the table:

# Financial table with full visible controls and timestamp
[tablecrafter source="https://api.example.com/stocks.json"
  auto_refresh="true"
  refresh_interval="60000"
  refresh_indicator="true"
  refresh_last_updated="true"]

Resilience: retries and backoff

Live sources fail intermittently. The auto-refresh engine handles transient errors gracefully so a single bad response does not break the table.

Configuring in the Gutenberg block

Every auto-refresh option is available without writing a shortcode. In the block editor, add a TableCrafter block and open the Auto-Refresh Settings panel in the block sidebar:

Changes preview live in the editor, so you can confirm the indicator and interval before publishing.

SWR background caching

Independent of the browser-side refresh, every rendered table is cached server-side using a Stale-While-Revalidate strategy handled by the TC_Cache class:

ℹ️

An hourly WordPress cron event (tc_refresher_cron) warms the cache for tracked source URLs, keeping frequently used tables hot. SWR runs whether or not auto-refresh is enabled.

Managing the cache with WP-CLI

TableCrafter registers a wp tablecrafter command for cache maintenance on the server:

# Clear all TableCrafter caches (HTML, data, export transients)
wp tablecrafter clear-cache

# Re-warm the cache for all tracked source URLs
wp tablecrafter warm-cache

Monitoring data-source health

For live tables, knowing when a source breaks matters as much as refreshing it. The TC_Data_Source_Health_Monitor class (added in 3.5.3) checks registered sources and can alert you when one degrades or fails — addressing the silent breakage problem where an upstream API dies and a table quietly goes stale.

The monitor is a singleton, retrieved and configured programmatically:

// Register a source and route alerts to a webhook + email
$monitor = TC_Data_Source_Health_Monitor::get_instance();
$monitor->register_source( 'https://api.example.com/live-data.json', [
    'expected_keys' => [ 'price', 'symbol' ],
] );
$monitor->configure_notifications( [
    'threshold' => 1,
    'webhook'   => 'https://hooks.example.com/tablecrafter',
    'email'     => [ 'ops@example.com' ],
] );
$result = $monitor->check_health( 'https://api.example.com/live-data.json' );

The webhook payload includes the source URL, status, response time, error message, a severity level, and the plugin version — ready to drop into Slack, PagerDuty, or any incident pipeline via an inbound webhook.

Choosing an interval

Match the refresh cadence to how fast your data actually changes, and keep upstream rate limits in mind.

Use caseSuggested interval
Crypto / stock tickers3000060000 (30s–1min)
Inventory / order status300000 (5min, default)
Sports scores / live events30000 (30s)
Reports / analytics dashboards9000003600000 (15min–1hr)

Because smart pausing suppresses refreshes during interaction and on hidden tabs, short intervals are far less wasteful than they sound — most polls happen only while a table is visible and idle.

Next, see data-sources.html for connecting JSON, CSV, and Google Sheets sources, and caching-performance.html for tuning SWR and the cache-warming cron.