Are Single Page Applications (SPAs) the only web architecture you should be considering for new development?
Absolutely not.
It is true SPAs offer advantages over MVC’s Multiple Page Application structure, but the reverse is also true. As is true across all decisions in software development, this is a choice with trade offs. Some of those trade offs might disappear with time, making SPAs truly dominant, but that isn’t the case in 2016.
Features of SPAs
- Requires JavaScript (JS) enabled clients
- SPAs are client heavy
- Large initial page load
- Initial page load worsens as the application grows larger, which might be seen as a plus to encourage small focused applications
- HTML renders with client JS
- SPAs are web server light
- No server side HTML rendering
- Well suited to situations where ability to take Distributed Denial of Service (DDOS) sized traffic loads is important
- Could be premature optimization in enterprise contexts, where database is often the performance bottleneck
- SPA libraries and frameworks are diverse and rapidly evolving
- Hard to pick small set of long term well supported technologies to deeply invest in
- SPA patterns are not widely understood.
- Experienced developers often do not have the skills already
- New developers take longer to learn SPA patterns
- SPAs are difficult to perform Search Engine Optimiztion (SEO) on.
- Web crawlers cannot index the different “pages” of a SPA application
- Makes SPA a poor choice for Content Management System (CMS) style media or e-commerce sites.
- Effectively limits application to a single point of entry
- Could be good for sculpting easy to understand user experience, but lacks customization or immediacy to information delivery
- Extra work is required to manage URL history
- Hiding workflows that users are not authorized for is more difficult
- AJAX endpoints are still protected, but existence of endpoints are difficult to hide in initial page load
Trends
- Clients are JS enabled more frequently
- Clients are increasingly more powerful
- Consumer applications are experiencing DDOS sized traffic loads more often as more people go online
- Web servers are becoming cheaper and more horizontally scalable with proliferation of containerization and cloud infrastructure
- Microsoft is making investments in Angular 2 with TypeScript
Conclusion for Today
SPAs are a toolset that in certain subsets of the development industry may make sense to adopt whole hog. Especially if management is willing to spend the time to bring both new and old developers up to speed, and either move to new JS libraries as they become dominant or to support legacy frameworks on their own. If these are true, and problem set supports the case of offloading work to the client, significant performance gains can be realized.
MVC however is not dead. The performance benefits of SPAs never materialize in many applications while the costs still remain. Advantages in SEO and security may also be deciding factors for many applications.
Speculations on Tomorrow
SPAs are going to continue growing in suitability, both in increasing benefits and applicability. It is reasonable to believe they may also mature, standardizing around stable major frameworks and practices. However the decreasing costs of web server HTML rendering, is going to continue keeping MVC a good choice for applications with limited numbers of users, limited development budgets, or SEO concerns.
Developers of MVC applications should familiarize themselves with SPA best practices, cherry picking use cases for their applications to transfer techniques. New applications should be carefully evaluated for expected usage and requirements.