Chapter 9. Readying our SPA for production

 

This chapter covers

  • Optimizing SPAs for search engines
  • Using Google Analytics
  • Placing static content on a content delivery network (CDN)
  • Logging client errors
  • Caching and cache busting

This chapter builds on code we’ve written in chapter 8. We recommend copying the entire directory structure of that chapter into a new “chapter_9” directory and updating the files there.

We’ve finished writing a responsive SPA using a well-tested architecture, but some challenges remain that are less about programming and more about operations.

We need to adjust our SPA so that users can use Google and other search engines to find what they need. Our web server needs to interact with the crawler robots that index our content differently because the crawlers don’t execute the JavaScript our SPA uses to generate the content. We also want to use analytics tools. On a traditional website, analytics data is typically collected through a JavaScript snippet added to every HTML page. Because all of the HTML in an SPA is generated by JavaScript, we need a different approach.

9.1. Optimize our SPA for search engines

9.2. The cloud and third-party services

9.3. Caching and cache busting

9.4. Summary