I have developed an angular
application where the list of categories
is loaded on the home
page. To achieve this, I am calling the getCategories()
function on ngOnInit
, so every time the home
page is visited, all categories are fetched from the database and displayed. While this functionality works correctly, a problem arises when a user navigates to a specific category
page from the home
page and then returns back to the home page. In such instances, the app fetches all categories from the database and renders them again on the home page. As a result, the app ends up making multiple http
requests every time the home page is revisited.
Hence, my query is whether there exists a technique or method to eliminate these redundant http Get
calls. Is there a way to store the retrieved data once the home page is initially loaded, perhaps in a local scope
, so that whenever the user returns to the home page, the data can be fetched from this stored location rather than querying the database again?