I'm wondering how frontend and backend should interact through http requests in a Single-Page-Application (SPA), considering green IT recommandations (such as limiting the number of http requests) and what consequences it would have on the way I write my backend controllers. I'm looking for a pattern to use in any case (if possible)
Basically, I have a Page in frontend that will need multiple data from backend (let's say: the page's content and some featured news).
What would be the best choice? (considering green IT, but also performance, dev patterns, etc)
- Having an action in the controller for each request (2 actions here). So, the frontend would need 2 http requests to retrieve data.
- Having one and only one action in the controller for both request. So, the frontend would need only 1 (but heavier?) http request to retrieve data.
And is this choice the one to use on the whole project (for a Page that needs 100 different data)? Or should I need to use the other pattern depending on the case (in which cases?) ?
Aucun commentaire:
Enregistrer un commentaire