Use WordPress as a Static Website Generator
By Mark Gavalda, Updated: June 5, 2017
That’s one of the reasons why more and more people turn to static website generators. Jekyll is one of the most popular ones, which you can use to host your whole website or blog on GitHub Pages and push your new content with one command. The downside? For the laymen it’s not easy (to say the least) to set it up, and even for developers it can be time-consuming. If you have a free afternoon to learn more about Jekyll then take a look at this article by Barry Clark, it’s the most detailed tutorial on the topic that I know of.
However, if you’d rather just speed up your current WordPress site, you can do that too! You just have to remember that if you use WP in that way, you’ll have to make sacrifices: there won’t be any “real-time” dynamic content on your site, at all. No “recommended articles for you” widget that’s different for each visitor, you can’t use WordPress’s built-in commenting system and so on. Everything that is server-side (PHP) generated will become static and updated once a day for example.
There are a couple of WordPress caching plugins that you can use to create static HTML files of your posts and pages, but if you’re using Nginx as your web server (and if you don’t, you really should, but that’s a topic for another article) you can just flip the full page caching switch on and set it to expire in a day or a week. The longer period you can “afford” to set it to, the better. What happens next is that the first visitor will have the server generate the complete, cached HTML files and any consecutive visitors within the predefined expiration period will get served those files.
For comparison, based on our recent tests while a WordPress page with a premium theme and WooCommerce activated will take about 250ms to get fully built and served, you can go as low as 110ms with HHVM, but the same page will be handed over in just 2 to 5ms when it comes from a prebuilt FastCGI cache! That’s a 50x performance improvement, not to mention that it won’t eat up hardware resources, so you’ll be able to handle enormous waves of traffic if it comes to that!
How to set it up, you ask? Well if you manage your own servers here’s an extremely detailed guide by DigitalOcean that you can follow. If you have a shared/managed hosting account, you can ask your support team to set it up for you. And if you’re a Kinsta WordPress Hosting client, you open up a ticket with our support team within your MyKinsta dashboard and request a longer cache duration.
Just please make sure first that you fully understand the consequences of doing so.