Background Sync


Background Sync keeps your imported data current automatically using WordPress Cron. Instead of manually running import tasks, the plugin periodically checks for new games, updated scores, roster changes, standings updates, and more — all in the background.

Admin Menu: API & Import > API Config > Background Sync section

🔄 Enabling Background Sync

  1. Go to API & Import > API Config
  2. Scroll to the Background Sync section
  3. Toggle Enable Background Sync to On
  4. Configure individual task toggles and intervals
  5. Click Save Settings

When enabled, a master cron event is scheduled that dispatches individual sync tasks based on their configured intervals. Each task can be enabled or disabled independently, and each has its own interval dropdown.

API Config page showing the Background Sync section with enable toggle and task grid with interval dropdowns

📋 Sync Tasks

Six core sync tasks run on configurable intervals. Two additional tasks (Highlights and Odds) run on a daily schedule with their own settings.

Core Sync Tasks

TaskInterval OptionsDefaultWhat It Does
Game Details4h / 6h / 12h6hFetches scores, lineups, and stats for finished games
Standings6h / 12h / 24h12hUpdates league standings and rankings
Schedule6h / 12h / 24h12hSyncs kickoff times, venue changes, postponements
New Fixtures12h / 24h / 48h24hDiscovers newly added games (playoffs, added matchdays)
Team Rosters3d / 7d / 14d7 daysUpdates player lists and injury status
Brackets6h / 12h / 24h12hUpdates playoff bracket results

Highlights (Daily)

Located in the Highlights section on the same API Config page (below Background Sync). When the Auto-Fetch Highlights toggle is enabled, a daily cron job searches for YouTube highlight videos for recently finished games.

  • Lookback window: 3, 5, or 7 days (configurable) — how far back to search for games needing highlights
  • Batch size: Up to 10 games per cron run
  • Highlights typically appear on YouTube 24-48 hours after a game ends
  • The plugin validates video availability before saving — dead or removed videos are automatically skipped

Odds (Daily)

When Auto-Refresh Odds is enabled in Plugin Settings, a daily cron job fetches betting odds for upcoming games.

  • Pace: 1 date per sport per cron run
  • Staleness threshold: 6 hours — dates already fetched within 6 hours are skipped
  • Lookahead window: Configurable (7, 14, 21, or 28 days ahead)
  • Covers all leagues on each date, not just your imported seasons

Task Details

Game Details is typically the most important sync task. It picks up games that have finished since the last sync run and imports their full statistics — box scores, play-by-play, and team stats. This is the same process as running the Finished Details import task manually, but automated.

Standings should run at least daily during an active season. Standings data powers the standings blocks on team and season pages.

Schedule catches postponements, venue changes, and time adjustments. Important if you display upcoming game schedules or fixtures.

New Fixtures discovers newly scheduled games. Most useful during playoff season when matchups are determined by results.

Team Rosters tracks trades, free agent signings, and injury list changes. Can run less frequently (3-14 days) since roster changes are less time-sensitive.

Brackets only matters for leagues with knockout/playoff brackets. Can be disabled entirely for regular-season-only leagues.

How It Works

Master/Chain Pattern

Background Sync uses a master/chain execution pattern:

  1. A master cron event fires periodically (hourly)
  2. The master checks each task’s last run time against its configured interval
  3. Tasks that are due are dispatched immediately
  4. Each task runs independently — if one fails, others still execute
  5. Within each task, batches are chained with 30-second delays to prevent API rate limit issues

Smart Season Filtering

Sync tasks do not blindly process every season in your database. The system uses smart filtering:

  • Only processes seasons that have been imported (not just discovered via the hierarchy step)
  • Only processes seasons that have the required capabilities — for example, Standings sync only runs for seasons where standings data is available
  • Completed or archived seasons are automatically skipped

This means seasons you imported in previous years will not generate unnecessary API calls.

🕒 Recommended Configuration

Active Season (Games Being Played)

TaskRecommended Interval
Game Details4–6 hours
Standings6–12 hours
Schedule6–12 hours
New Fixtures12–24 hours
Team Rosters3–7 days
Brackets6–12 hours (if applicable)
HighlightsEnabled, 3-day lookback
OddsEnabled, 7-day lookahead

Off-Season

During the off-season, you can either disable Background Sync entirely or keep only the tasks that matter:

TaskRecommendation
Team Rosters7–14 days (track off-season moves)
New Fixtures24–48 hours (catch schedule releases)
All othersDisabled

WordPress Cron Limitation

WordPress Cron is not a real cron system. It is triggered by site visits — when someone loads a page on your site, WordPress checks if any scheduled events are due and runs them.

The problem: If your site has low traffic, scheduled tasks may run late or be skipped entirely.

Important

For reliable sync timing, set up a server-side cron job. This is especially important for live scores and game details — without real cron, updates may be delayed by hours on low-traffic sites.

Setting Up Server-Side Cron

  1. Disable WordPress’s built-in cron by adding this to wp-config.php:
define( 'DISABLE_WP_CRON', true );
  1. Set up a server cron job (via cPanel, Plesk, or SSH):
* * * * * wget -q -O /dev/null https://your-site.com/wp-cron.php

This triggers wp-cron.php every minute. This is required if you use Live Scores — the live polling pipeline needs to fire every 30-120 seconds. Even for background sync alone, every minute ensures tasks execute promptly.

Tip

Most managed WordPress hosts (Cloudways, Kinsta, WP Engine, GridPane) handle server-side cron automatically. Check your hosting documentation before setting it up manually.

API Usage Impact

Background Sync consumes API calls from your RapidAPI quota. The number of calls depends on which tasks run and how much data you have imported.

TaskAPI Calls Per RunNotes
Game Details2–5 per gameDepends on sub-options (lineups, team stats, incidents, highlights)
Standings1 per seasonSingle call per active season
Schedule1 per page per seasonChecks upcoming game pages
New Fixtures1 per page per seasonSimilar to Schedule
Team Rosters1 per teamOne call per team in active seasons
Brackets1 per seasonSingle call per season with bracket data
Highlights1 per gameUp to 10 games per daily run
Odds1 per date1 date per sport per daily run

Example: A site tracking 2 active basketball seasons with ~15 games finishing per day would use roughly 30–75 API calls for Game Details alone per sync cycle. Add standings, schedule, and other tasks for an additional 10–20 calls per cycle.

A paid RapidAPI plan with unlimited daily requests is recommended for sites using Background Sync. The sub-options in API Config (lineups, team stats, incidents, highlights) let you control how many calls each finished game consumes.

Troubleshooting

Sync Is Not Running

  • Background Sync disabled — Check API & Import > API Config and verify the master toggle is on
  • WP Cron disabled without server cron — If DISABLE_WP_CRON is set in wp-config.php but no server cron is configured, no scheduled events will fire
  • Low site traffic — WordPress Cron requires page visits to trigger. Set up server-side cron (see above)
  • API key invalid or expired — Verify your API key is active in your RapidAPI dashboard
  • Rate limit reached — If your daily API quota is exhausted, sync tasks will fail silently until the quota resets

Data Not Updating on the Frontend

  • Page cache serving stale content — If you use a page caching plugin, enable Page Cache Flush in Settings > Caching so pages refresh when data changes
  • Object cache stale — The plugin automatically flushes relevant caches after sync. If data still appears old, try the Flush All Caches button in Plugin Settings
  • CDN caching — If you use Cloudflare or another CDN, cached REST API responses may take time to expire. The plugin uses cache-busting hashes, but edge cache TTL overrides can delay updates

Inspecting Cron Events

Install the free WP Crontrol plugin to inspect scheduled events. Look for these cron hooks:

Hook NameTask
anwphub_sync_finishedGame Details
anwphub_sync_standingsStandings
anwphub_sync_kickoffSchedule
anwphub_sync_fixturesNew Fixtures
anwphub_sync_rostersTeam Rosters
anwphub_sync_cuptreesBrackets
anwphub_sync_highlightsHighlights
anwphub_sync_oddsOdds

If a hook is missing from the schedule, Background Sync may have been disabled and re-enabled — save the settings again to re-register the cron events.

Related

  • Import Workflow — Manual import as an alternative to Background Sync
  • Import Tasks — What each import/sync task does in detail
  • Live Scores — Real-time score updates during active games (separate from sync)
  • API Config — Full settings reference for the Background Sync section
  • API Usage — Rate limits and API call cost estimation
  • Caching — How the plugin caches data and flushes on sync