Skip to content

Simple guide · Core platform

Page status: Active

Fluid Active CPU Reduction

This update reduces avoidable Vercel Fluid Active CPU work in the NutsNews public web path while preserving the existing fallback model.

Visual overview

Primary diagram

System map

This update reduces avoidable Vercel Fluid Active CPU work in the NutsNews public web path while preserving the existing fallback model.

Render the repository-owned system map when you need it.

Diagram is not rendered yet.

View as text
Fluid Active CPU Reduction

This update reduces avoidable Vercel Fluid Active CPU work in the NutsNews public web path while preserving the existing fallback model.

flowchart TD
  accTitle: Fluid Active CPU Reduction
  accDescr {
    This update reduces avoidable Vercel Fluid Active CPU work in the NutsNews public web path while preserving the existing fallback model.
  }
  R[Public homepage request] --> S[Read precomputed public_feed_snapshot]
  S --> H[Extract latest 250 rows]
  H --> B[Derive top stories and sections]
  B --> A[/api/articles?home=1&lang=<language>/]
  A --> L[Batch load localized summaries from ids]
  R --> C[Homepage SSR returns initial 5 stories]
  C --> I[Infinite scroll cursor requests up to 15 rows]
  C --> M[homepage and article APIs set revalidate 900]
  M --> X[CDN cache: s-maxage=900, stale-while-revalidate=3600]
  R --> P[Middleware for public reader paths no longer runs]
  P --> N[Middleware still runs for /admin, /monitoring, /api/auth, /api/contact]
  N --> E[Errors still logged with full visibility]

Fluid Active CPU Reduction

Fullscreen diagram view.

This update reduces avoidable Vercel Fluid Active CPU work in the NutsNews public web path while preserving the existing fallback model.

The normal homepage path now reads the precomputed public_feed_snapshot once, scans the newest 250 rows, and derives:

  • the first five homepage stories
  • Community
  • Animals
  • Science
  • Wellness
  • Travel
  • Culture
  • Achievements

For translated home feeds, selected article IDs are deduplicated before localized summaries are loaded, so translation hydration is performed as one batched lookup instead of one lookup per section.

If the optimized snapshot path is unavailable, NutsNews falls back to the previous resilient main-feed and section reads.

Returning non-English visitors now load:

/api/articles?home=1&lang=<language>

The browser no longer launches one main-feed request plus seven category requests. The combined payload is served through the established /api/articles route so the existing multilingual E2E contract remains intact. /api/home-feed remains available only as a cacheable error fallback. Timestamp cache busting and public no-store behavior were removed from language restoration.

The initial server-rendered homepage remains five stories for a light first render. Infinite-scroll cursor requests now return up to 15 stories per batch, reducing repeated function invocations while keeping legacy offset pagination compatible at five stories.

Key public reader paths now use a 15-minute CDN freshness window:

s-maxage=900
stale-while-revalidate=3600

The homepage and article APIs use revalidate = 900.

Routine successful article, search, and home-feed requests no longer emit request_started events. Completion events use sampled info logging with a default 5% sample rate.

Optional override:

BETTER_STACK_INFO_SAMPLE_RATE=0.05

Valid values are clamped to 0..1. Errors continue to be logged at 100%.

Public security headers moved to static Next.js header configuration. Runtime middleware is now matched only for operational/no-store paths:

/admin/*
/monitoring/*
/api/log-test/*
/api/auth/*
/api/contact

This avoids running middleware for ordinary public reader traffic.

A new Fluid Active CPU regression test prevents these specific regressions:

  • timestamp cache-busting on public feed restores
  • public no-store language restores
  • seven-request category fan-out
  • loss of 15-minute cache settings
  • loss of 15-story cursor batches
  • reintroduction of request-start logging
  • broad middleware matcher restoration

A new all-tests immutable guard also locks every established test-like file after merge. New test files may be added, but once present on main they may not be modified or deleted unless the PR title or PR body contains a standalone line exactly equal to:

APPROVED

Run from the application repository:

Terminal window
node scripts/fluid_active_cpu_regression.mjs
node scripts/immutable_all_tests_guard_regression.mjs
cd web
npm ci
npx tsc --noEmit
npm run lint
npm run test:security-headers
npm run build
npm run test:e2e:offline

After deployment, verify:

Terminal window
curl -I https://www.nutsnews.com/
curl -I 'https://www.nutsnews.com/api/articles?page=0'
curl -I 'https://www.nutsnews.com/api/articles?home=1&lang=fr'

Expected cache policy includes a 900-second shared cache window. Then inspect Vercel Usage and compare:

  • Fluid Active CPU
  • Function Invocations
  • ISR Writes

Use the same traffic window before and after deployment when possible.