Build Static Websites
eager.io
eager.io
But we definitely serve too much of the web from dynamic php sites that could easily just be HTML files sitting in a cache or on a file system.
In my experience, it's significantly easier to scale an API than a traditional (PHP-style) web server.
Something of an aside: You really don't need localStorage to do this. You can still use cookies, you just can't use HttpOnly cookies, and in fact that's what the localStorage polyfills I've used fall back to. The trade-off (drat! there's always one of those) of both localStorage and non-HttpOnly cookies is that it once again becomes easy to steal user access credentials outright if you can manage an XSS attack, which is what HttpOnly cookies helped prevent in theory. On the other hand, in practice XSS attacks can still usually steal an account even with HttpOnly cookies (for instance, by sending a request to change a user's password, which dutifully sends along the valid cookie anyway) or do other nefarious things, so you just can't let XSS happen either way.
Another question is: Is the user experience of applications built this way as good? It definitely can be once everything is loaded and churning along, but the initial load can be quite slow and choppy as data comes back piecemeal. Server-rendering the initial page and doing updates through an API is, I believe, the way forward, but it's still tricky and inconvenient to do. And then you once again need to scale the rendering of full pages server-side!
tl;dr; Yes, that's a good approach, but not a panacea.
Node.js-based, lots of plugins available via npm, sane themeing syntax. I have a script that generates my site and then pushes it to S3.
My site, such as it is, is available here: https://github.com/drhayes/drhayes.io
https://middlemanapp.com https://github.com/middleman/middleman
Middleman is just simple enough that you can quickly build out an entire website/blog with great functionality, but extensible enough that you can write some custom Ruby to do that one specific thing you want.
I also really like how middleman can essentially use any markdown renderer or template engine. As someone that loves erb, Sass and Rake, Middleman just makes the most sense.
A few sites I've built with middleman
That being said, I'm been using gulp to hack together a system when the site isn't something conventional like a blog, marketing page or docs that many of these generators excel at.
But beware, if your website start to grow and becomes more dynamic, take a step back and rethink if you should still go with all that generation. Could be a pain in the future.
Someone correct if I'm wrong, but the people behind the The New York Times website had to do a major rewriting of their code base due to that (I remember seeing some presentation about it some time ago, but I can't find the link nowadays...).
Every 2 minutes the site gets fully spidered, dumped into flat HTML files. And if the dump is not successful, because of a database connection or any problem at all, it doesn't get saved and doesn't overwrite the public_html dir.
I've been toying with the idea of creating a product / service that would let you choose which internal links went to the static copy and which would be forwarded to the original site so that dynamic stuff like commenting could still work (although perhaps display would be delayed), but everything else could be static / cached.
Honestly I think a proof of concept could be done using something like wget to mirror the site and a little ruby or awk to do the specific link rewriting.
Edit: WP caching benchmarks http://cd34.com/blog/scalability/wordpress-cache-plugin-benc...
Here is one I found [1], I've never used it though, so I don't know how good it is. I'm sure there are others as well. It would be nice if there were a static site generator with an interface as nice as WP.
oh man, that's a great idea, that would grow WP adoption rate by 1000x
Something like call partial (list of recent blog posts) which itself could be static. Two-to-three static calls and you could have a very clean and robust system with no database queries.
Most web shared hosting where custom wp are configured use Apache which doesn't solve the problem because apache (2.2, the 2.4 version should have improved a bit) spawns processes containing the PHP modules, therefore using more ram than it actually needs to process an html page.
This issue is vastly solved if you have a Nginx webserver with a good configuration.
You can also improve that if you use memcached and the nginx memcached_pass, which directly outputs the memcached cached html without passing through php, giving a super-boost to response times. (to use this feature, checkout the WP-FFPC plugin) If one page ends up on reddit/hackernews/producthunt homepage, a system designed like this should support the bump with relatively small issue.
Obviously if many people start commenting you will still have performance issue because that's when the php part is called (and that's the most memory expensive).
I came across this a little while ago: https://decoupled.de/
But if the problem is about resisting traffic, then that's the reason why CDNs were invented: cloudflare is an example, and the seemingly unactive coralcdn (http://www.coralcdn.org/), even simpler to "install" and has a very interesting architecture (I encourage anyone interested in P2P stuff to take a look at their papers).
Keeping your server behind some form of CDN also has the advantage that you keep control over the actual storage of your data.
You can then use TravisCI (or the like) to trigger the site rebuild and deployment.
A static site needs also to be served. HTML-files are on the Servers Harddrive. They have to be read and send to the client.
A clever Caching-Strategy might beat this aproach by reading the files once and Serving the content from memory. When I write "reading the files once", this also includes making a db-query, rendering a HTML-Site and caching the result in a Tool like memcache to serve it from there.
(On the other hand, I don't like using javascript for things that don't need it, so it's not soo clear cut...)
You can see many of the things you can do just on the client in our apps list: https://eager.io/apps. We don't have a counter in there yet, but it's certainly possible.