feat(perf-client): env flags to suppress cache-busting headers - #2613
Open
michaelfeil wants to merge 1 commit into
Open
feat(perf-client): env flags to suppress cache-busting headers#2613michaelfeil wants to merge 1 commit into
michaelfeil wants to merge 1 commit into
Conversation
Add PERFORMANCE_CLIENT_DISABLE_TIMEOUT_HEADERS and PERFORMANCE_CLIENT_DISABLE_REQUEST_ID_HEADER env vars (truthy: 1/true/yes/on). When set, the client omits the time-based Request-Deadline-Ms / Request-Timeout-Ms headers and/or the per-request x-baseten-customer-request-id header, which otherwise break header-based downstream cache keys. Default behavior is unchanged (headers emitted). Values are cached via OnceLock.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The performance client emits two headers that vary per request and break header-based downstream caching (e.g. when a cache server SHA-hashes request headers as the cache key):
Request-Deadline-Ms— time-based (now + timeout), recomputed every request (core/src/http_client.rs)x-baseten-customer-request-id— unique per request (UUID + batch/retry/hedge counters)When the user has no control over the cache server, the only lever is to stop emitting these headers at the client. This adds two opt-in env flags (default behavior unchanged):
PERFORMANCE_CLIENT_DISABLE_TIMEOUT_HEADERS— suppressesRequest-Timeout-Ms/Request-Deadline-MsPERFORMANCE_CLIENT_DISABLE_REQUEST_ID_HEADER— suppressesx-baseten-customer-request-id(internal retry/hedge/tracing behavior is unaffected; only the emitted header is skipped)Truthy values:
1,true,yes,on(case-insensitive). Values are read once and cached viaOnceLockto avoid a syscall per request.Changes
core/src/constants.rs: new env var name constantscore/src/http_client.rs:env_flag_enabledhelper + cached flags;add_timeout_headersand bothCUSTOMER_HEADER_NAMEinjection sites are now gatedREADME.md: document the two new env varsTest plan
cargo test -p baseten_performance_client_core(49 passed, incl. newhttp_client::tests*`)cargo clippy -p baseten_performance_client_core --all-targets -- -D warningscleancargo fmt --checkcleancargo checkfor python + node bindings (no public API change)Notes