I’ve been seeing more frameworks lately for generating static websites. The reason for these becoming more popular recently is the result of several developments.
- Cheap shared hosting is notoriously unreliable, slow servers overloaded with too many websites and hacked servers being able to infect and hack many other sites at once.
- The scalability, performance, uptime and low cost provided by Amazon S3 and their CloudFront CDN service.
The difference in cost between a scalable dynamic site and a scalable static website can be staggering. So if there is a way you can convert a website over to be static (perhaps with a daily or hourly upload of new content) it may be worth your while.
A website with 1 million page views per month on Amazon S3 with CloudFront would cost roughly $6/month depending on the size of the assets. Building up a simple server configuration with 1 database server and a webserver with small EC2 instances would bring the costs up around $150/month.
One of the nice things about developing a static website is that you can script things however you want to. Concatenate strings in bash or PowerShell or go all the way to having a complex database backed CMS system and template engine. It also means massively less complex server infrastructure. No more nginx reverse-proxied gunicorn server paired with a database server and a host to tools to monitor uptime and send alerts should things break.
It’s for these reasons that I am working on my next project to have a static website backend instead of a dynamic django app.
Using a template engine like Jinja2 it is trivial to convert content over to static files ready to be uploaded.
Some tricks may be needed to handle things in a more complex static site. Perhaps a small light server to refresh the static content every hour, or to run scheduled tasks, or to do other various asynchronous jobs. Still the costs can be brought way down if your servers don’t have to handle the web requests.