I am currently developing an Angular front-end for a web-based application. One of the challenges I am facing is that all sub-page drill downs, implemented as different Angular components, make identical API calls in the ngOnInit() method. This repetitive calling is causing performance issues as the user traffic increases. I am seeking a solution to cache this data so that it can be utilized across multiple pages, thereby reducing the number of API requests.
ngOnInit() {
if (this.api.validInputParams()) {
this.api.getLiveData().subscribe((response) => {
// Perform page-specific functionality and filtering
}, (error) => {
// Any errors should be handled by the HttpInterceptor
});
}
}