On my Angular page, I have set up routing using <router-outlet></router-outlet>
. When an user first loads the page (like the home page), I send a total of 3 requests:
/api/GetCategories
/api/GetRecentPosts
/api/GetAllPosts
When I click on a post, only one request is sent: /api/GetPost/{id}
Because of this, if I update my categories or create a new post, the user won't see them until a page reload (F5 for example).
I know a proper way to solve this: Create a socket connection between my server and the client, and each time a new post has been made, it's automatically updated on the page. No caching, no random interval GET requests, and so on. An elegant solution. However, it's also the most painful in terms of maintenance and so on.
What other options do I have? Send the request every page load, but cache the result on my backend? Create some kind of token that dies after a certain amount of time, and then it sends a request to update the categories and posts? Something third?