I'm writing an Angular SPA app, that uses HttpClient to get values from my backend.
What is the easy way to tell it not to cache? The first time I ask it gets the value, then it refuses to make subsequent queries.
Thanks, Gerry
I'm writing an Angular SPA app, that uses HttpClient to get values from my backend.
What is the easy way to tell it not to cache? The first time I ask it gets the value, then it refuses to make subsequent queries.
Thanks, Gerry
Using meta HTML tags, Disable browser caching:-
or,
Add
headers
inhttp
request as:-As answered by Pramod, you can use http request interceptor to modify or set a new header on the request. Below is a much simpler way of setting headers on http request interceptor for Later angular versions(Angular 4+). This approach would only set or update a certain request header. This is to avoid removing or overriding some important headers like the authorization header.
HTTPInterceptors are great way to modify HTTP requests occurring in your application. It acts as an injectable service that can invoke when HttpRequest occurs.
HTTP Interceptor:
Using Interceptor: