NG.VII · Angular 22 practice question
A developer calls `http.get('/sensitive/data', ...)` and needs to tell a caching interceptor to skip caching for this specific call. How should they pass the `CACHING_ENABLED` token value?
Check answer and explanation
Correct answer: Pass an `HttpContext` instance with `.set(CACHING_ENABLED, false)` in the request's `context` option.
Explanation
You provide per-request `HttpContextToken` values by passing `new HttpContext().set(TOKEN, value)` in the `context` option of the `HttpClient` call.
Common trap
URL fragments are not sent to servers or read as `HttpContextToken`s. Custom HTTP headers are transmitted over the wire to the backend, whereas `HttpContext` stays client-side for interceptors.
Source: Angular docs: Interceptors — Setting context tokens when making a request
Checked against the cited text on 2026-11-27.