Skip to content

Cache Prebid placeholders briefly in the browser - #1734

Open
ChristianPavilonis wants to merge 2 commits into
mainfrom
fix/1729-prebid-placeholder-cache
Open

ChristianPavilonis wants to merge 2 commits into
mainfrom
fix/1729-prebid-placeholder-cache

Conversation

@ChristianPavilonis

@ChristianPavilonis ChristianPavilonis commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Next.js can load the publisher's Prebid script before hydration adds a preload for the same URL. With no-store, Chrome fetches the Trusted Server placeholder again and warns that the preload went unused.

Serve only the placeholder with Cache-Control: private, max-age=60 and no shared-cache headers. The real Prebid bundle is unchanged. If Trusted Server stops intercepting the script URL, a browser can still reuse a fresh placeholder until it expires.

Why 60 seconds?

The preload arrived 800 ms after the script in the reproduction. A 60-second TTL let Chrome reuse the placeholder and eliminated the extra request and warning. We did not test shorter positive TTLs.

The placeholder is served at the publisher’s real Prebid URL. A longer TTL would give browsers more time to reuse the empty placeholder after Trusted Server stops intercepting that URL, delaying the return of the real script without helping the late preload. private keeps the placeholder out of shared caches.

Changes

File Change
crates/trusted-server-core/src/integrations/prebid.rs Set the short private cache policy and assert the exact header and absence of shared-cache headers.
docs/guide/integrations/prebid.md Document the placeholder's browser-only cache policy.

Closes #1729

Spec

Not a feature.

Test plan

  • Chromium 155 against a local Axum fixture that inserts the script before the preload: two network requests and a warning on main, one network request and no warning with this patch.
  • Repeat with conflicting public cache settings: the final response stays private, max-age=60 and has no shared-cache headers.
  • 181 focused Prebid tests and 60 Axum tests passed.
  • Rust format, core and Axum Clippy, and Prettier for the changed guide passed.
  • Full cross-adapter CI.

Let a late script preload reuse the placeholder without making it shared-cacheable. The short lifetime limits how long a browser can reuse the placeholder after Trusted Server stops intercepting the publisher script URL.
@ChristianPavilonis
ChristianPavilonis marked this pull request as ready for review December 4, 2026 17:03

This branch has not been deployed

No deployments
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.

Prebid script placeholder is served no-store, causing a second request and an unused-preload warning on Next.js pages

1 participant