3 Composition with Ajax and server-side routing

This chapter covers:

  • Integrating fragments into a page via Ajax
  • Applying project-wide namespaces to avoid style or script collisions
  • Utilizing the Nginx web server to serve all applications from one domain
  • Implementing request routing to forward incoming requests to the right server

We covered a lot of ground in the previous chapter. The applications for two teams are ready to go. You learned how to integrate user interfaces via links and iframes. These are all valid integration methods, and they provide strong isolation. But they come with trade-offs in the areas of usability, performance, layout flexibility, accessibility, and search engine compatibility. In this chapter, we’ll look at fragment integration via Ajax to address these issues. We’ll also configure a shared web server to expose all applications through a single domain.

3.1 Composition via Ajax

Our customers love the new product page. Presenting all recommendations directly on that page has measurable positive effects. On average, people spend more time on the site than before.

But Waldemar, responsible for marketing, noticed that the site does not rank very well in most search engines. He suspects that the suboptimal ranking has something to do with the use of iframes. He talks to the development teams to discuss options to improve the ranking.

3.1.1 How to do it

3.1.2 Namespacing styles and scripts

3.1.3 Declarative loading with h-include

3.1.4 The benefits

3.1.5 The drawbacks

3.1.6 When does an Ajax integration make sense?

3.1.7 Summary

3.2 Server-side routing via Nginx

3.2.1 How to do it

3.2.2 Namespacing resources

3.2.3 Route configuration methods

3.2.4 Infrastructure ownership

3.2.5 When does it make sense?