Skip to content

fix(seo): keep stale sitemap cache and schedule sitemap source warm#2816

Merged
fermatmind merged 1 commit into
mainfrom
sitemap-cache-invalidation-repair-2026-07-07
Jul 7, 2026
Merged

fix(seo): keep stale sitemap cache and schedule sitemap source warm#2816
fermatmind merged 1 commit into
mainfrom
sitemap-cache-invalidation-repair-2026-07-07

Conversation

@fermatmind

Copy link
Copy Markdown
Owner

Problem

  • Sitemap-source cache had a permanent stale gap: 2,387 cached entries vs 2,389 generator output (observed 2026-06-03)
  • After article publish, the sitemap-source API returned only ~20 fallback paths — not ~2,389 actual paths
  • The warm command existed but was never scheduled, so caches never auto-rebuilt

Root Cause

Two bugs:

  1. seo:warm-sitemap-source-cache never scheduled — the command was implemented but never added to Kernel::schedule(). After the fresh cache TTL (10 min) expired, the API fell back to stale; after stale expired (24h) or article publish flushed both, the API fell back to ~20 hardcoded paths — and stayed there.

  2. flushArticleDiscoverabilityCaches() deleted both fresh AND stale — on article publish, both CACHE_KEY_FRESH and CACHE_KEY_STALE were deleted, leaving only the fallback. Since no scheduled warm existed, this was effectively permanent.

Fix

File Change
SeoDiscoverabilityCacheInvalidator.php Stop deleting CACHE_KEY_STALE — retain as safety net during gap window
Kernel.php Schedule seo:warm-sitemap-source-cache --json every 10 min, withoutOverlapping()
ArticlePublishDiscoverabilityCacheInvalidationTest.php Assert stale cache is retained after publish

Runtime Impact

Before: Article publish → fallback (~20 paths) until manual warm

After: Article publish → stale cache (~2,389 paths) for max 10 min gap, then fresh. If warm fails, stale retained.

Validation

php artisan test --filter ArticlePublishDiscoverabilityCacheInvalidationTest
# 3/3 PASS

php artisan test --filter "Sitemap|sitemap"
# 79/81 PASS (2 pre-existing failures unrelated)
#   - EnParity03ContentPagesParityImportPackageTest
#   - GlobalEnZhParityP001ContentHelpPolicyDiscoverabilityTest

Impact

  • Search submission: none
  • Deployment: takes effect on next normal fap-api deploy
  • CMS: no changes

Explicitly Deferred

  • Non-article content type cache invalidation (personality, career, topics, content pages)
  • Frontend sitemap.xml rebuild trigger
  • Search submission (Google/Baidu/Bing/IndexNow)
  • IQ scoring remediation
  • MBTI funnel analysis

- retain stale sitemap-source cache on article publish as fallback safety net
- schedule seo:warm-sitemap-source-cache every 10 minutes without overlapping
- update article publish discoverability cache invalidation test
- no CMS writes, no search submission, no deployment
- sitemap suite has 2 pre-existing unrelated failures
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@fermatmind fermatmind merged commit 1fb3c0b into main Jul 7, 2026
15 checks passed
@fermatmind fermatmind deleted the sitemap-cache-invalidation-repair-2026-07-07 branch July 7, 2026 15:14
fermatmind added a commit that referenced this pull request Jul 7, 2026
…pp.php (#2817)

Root cause: The application uses Laravel 11+ bootstrap/app.php ->withSchedule()
pattern for schedule registration, which takes precedence over
Kernel::schedule(). PR #2816 added the warm command to Kernel::schedule()
(dead code path) but not to bootstrap/app.php (active path).

Fix: Add seo:warm-sitemap-source-cache --json to the ->withSchedule()
closure in bootstrap/app.php at everyTenMinutes().

Also add SitemapWarmSchedulerBootstrapTest to prevent regression.

Note: email:lifecycle-rollout, commerce:repair-paid-orders, and
commerce:repair-post-commit-failed have the same root cause and are
registered in Kernel but missing from bootstrap/app.php — a separate
follow-up PR should address those.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant