Mirror Deployment

November 15, 2014 by Alex Thompson

The new Mirror Deployment feature enables dynamic content management to leverage high performance static web hosting.

The Choice

Static websites offer several benefits like fast performance and the simplicity of not maintaining server code. The drawback is that content management is much harder. If you want to make a change to a menu or header you might have to apply that change to thousands of static files. This is why the conventional option is a database driven CMS where broad changes can be applied easily.

For rarely changing websites, static website generators have gained popularity as a way to keep the dynamic templating of a CMS while getting the static benefits. But static generators typically run offline so you lose the edit from anywhere capabilities of a hosted CMS.

Really the best of both worlds is to have an online CMS that publishes to static hosting. Many large CMS driven sites operate this way but the content deployment mechanism is additional infrastructure to maintain and therefore unattractive to smaller sites. Primoca now bridges that gap with our new Mirror Deployment feature.

Mirror Deployment

Mirroring is essentially a single site web crawl. You begin the mirror by entering a start URL to your source web content (can be any public URL). Primoca crawls through all your links and saves the output of each request as a static file in your Primoca site. The URL structure and internal links will be the same as your source hence the term mirroring. Mirroring is a one time snapshot so if you make content changes later just mirror the site again.

The first thing to keep in mind is your production domain name should resolve to your Primoca site. The source content needs to be on a different publicly accessible URL. Since both the source site and Primoca site are public, you also want to ensure that search engines don't index the source site and penalize you for duplicate content. This can be done in two ways:

  • A robots.txt file on the source site that blocks search engines. (as long as there is no link to it in the source content it will not be mirrored so the Primoca site can have a different robots.txt that allows indexing)
  • Enable basic authentication on the source site. The mirror feature also accepts a basic username and password allowing it to mirror the source site while denying access to search engines.

Use the free clouds

A source site can be anything, a Wordpress site, a Drupal site, or even a custom CMS you wrote yourself. The best part is many cloud providers offer a free tier when using one of their sub-domains instead of your custom domain. This is perfect for using Primoca because your production domain will point to Primoca and your source site doesn't need a custom domain.

This blog is hosted precisely that way. It is an ASP.NET site that is hosted for free in Microsoft Azure websites then mirror deployed to Primoca. The source code for the blog is on Github to give you some ideas.

The same could be done in other languages or cloud providers such as Heroku or AWS. One more benefit of this architecture is the source site doesn't need to be very robust or reliable. It just needs to work while its being mirrored since the real traffic is being served by your Primoca site. Therefore the free cloud options are completely viable.

As always, this is part of our commitment to bringing you the easiest and highest performance web hosting experience on the planet.

Tags: Static_Websites Performance Blog