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 v
How about add salt to url:
const salt = (new Date()).getTime();
return this.httpClient.get(`${url}?${salt}`, { responseType: 'text' });
Same concept is used for static resource links in html (css or js) to trick the cache. Adding dynamic salt to url causes fresh loading of target each time because url is different every time, but in fact it is the same.
/static/some-file.css?{some-random-symbols}
I used date because it guarantee me unique number without using random and so on. We can just use incrementing integer for each call as well.
The code provided above worked fine for me in case when I couldn't change server configuration.