-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
Which @angular/* package(s) are relevant/related to the feature request?
common, platform-browser
Description
After I activated provideClientHydration() in my web application, I have noticed that GET requests from HttpClient are being cached internally by Angular, even if they are requests with "Authorization" headers. It's taken me a whole day to figure it out.
I've then tested with provideClientHydration(withNoHttpTransferCache()), and the extrange behavior stops happening. Nonetheless, I get the benefit of HttpClient caching when hydration is activated for GET requests without "Authorization" header. That being said, I'm finally trying the following configuration, which I think should be by default:
provideClientHydration(withHttpTransferCacheOptions({
filter: req => req.method === 'GET' && !req.headers.has('Authorization'),
})),Proposed solution
Stop provideClientHydration()from caching HttpClient's GET requests with "Authorization" header by default.
Alternatives considered
More documentation on how provideClientHydration() works along with HttpClient and caching.
Also, in the following links I don't get what the default behavior or filters are:
https://angular.io/api/platform-browser/withHttpTransferCacheOptions
https://angular.io/api/common/http/HttpTransferCacheOptions