Posted by Neil Young on June 28, 2016
Since these frameworks have allowed for Single Page Applications (SPA’s) to be widely used there is something that has been a thorn in the side of most developers for quite some time. SEO.
- Use Googles the hash bang implementation to serve static pages yourself. (Google still does this although you will need a headless browser such as PhantomJS to write a static version of the page and then point your .htaccess or other site configuration to tell the crawler to go to your static page)
- Separately create dynamic pages to compliment your front end views and serving these as part of your application e.g. use a PHP page for each of your views and write out your static content into the page as part of your markup (this can be cumbersome as the structure of your application may need to change)
- Use an external proxy service such as prerender.io to handle the crawling for you using a headless browser (this usually costs money).
So what other option is there?
Along comes Isomorphic applications.
If you prefer using Angular then at this time of writing you can use Angular’s own implementation of the isomorphic framework called Angular Universal which can be run either as a Node.js server underneath your Angular 2 code or if you are more comfortable on a ASP.NET server then this is also supported.
When it came to deploying my Isomorphic application I did this using a Dockerfile to build an image that would handle all of my node module deployment. If any new modules were added then I would simply build and commit my latest Docker image with my new modules. Once I have added my image to the Docker hub I would specify this image inside my project Dockerfile. This would then mean I would only need to add my working directory, expose the application port and start my application inside my new Dockerfile for my AWS deployment. Be warned though that running the Node.js server on a t1.micro or a t2.micro server seemed to time out when trying to deploy the build because of the processing of the node modules. Increasing the server capacity to a t2.medium server seemed to resolve this and I was able to run my isomorphic application successfully.