One of the most important things about running a website is having low loading times.
The answer to this is easy: people expect your site to load fast. If your site takes more than a few seconds to load, you lose a lot of potential visitors. In fact:
In a study done by Akamai, about half of web users expect a site to load in 2 seconds or less. If it isn’t loaded within 3 seconds, those users tend to abandon the site.
Google even uses site speed as part of their SEO ranking equation thing.
I’m sure you want to know how to speed up your site after those two sentences in the why section 🙂 . Well, anyways, here they are:
Use a CDN
If you’re too lazy to install and configure plugins, or just aren’t using WordPress, this can work fine as the only step you do, and will probably have one of the biggest impact of all these steps. Basically, what a CDN does is take the contents of your site, and puts them in tons of data centers all throughout the world. Then, when someone makes a request to one of the CDN-hosted contents, requests are routed to the nearest physical location, decreasing the time it takes to get said contents.
If you’re like me and don’t want to change all your image URL’s to point to a CDN, then I recommend CloudFlare. All you need to do is make a free account, and point your domain to them. Then, all traffic flows through them, and their complex systems take care of all the caching magic. Additionally, they cache some of your pages(such as the home page) every now and then to serve to visitors if your server is down, or takes too long to respond.
If you don’t know how to set this up, the easiest way is through CloudFlare. CloudFlare has an option under the caching menu to set the browser cache expiration date. The cool thing about doing this through CloudFlare is that they use whichever expiration time is larger, what you set on the dashboard, or your server’s original expiration date.
Similar to browser caching, CloudFlare can also take care of this for you 🙂 . Simply go to the speed tab, and the first section, called auto-minify, has three checkboxes for different things to minify. I recommend you select all of them, but be sure to check it doesn’t break your site. Most of the time nothing breaks, but in the rare case that it does, you want to make sure the least amount of visitors possible see a broken site.
Compression allows you to send the same information, but using less bandwidth. I don’t exactly know how this works, but it basically just reduces all the resources on the server, and the browser expands the resources upon receiving them. This allows for faster page load times, as less information needs to be sent in the first place. Since compression reduces the amount of time it takes to send the information, it also means more room will be available on your server faster to serve more requests, in case your site is popular and has more concurrent visitors that your VPS can handle during peak hours.
Yet again, CloudFlare can take of this for you without requiring any changes server-side. Simply enable Brotli compression under the speed tab, and CloudFlare will do the compression magic for you. You can check if your site already uses compression(which it likely does) by using https://checkgzipcompression.com.
Please comment anything I left out, and my next post will be about how to optimize WordPress by installing a few plugins. Also, let me know if you’d prefer longer posts like this about once or twice a week, or my usual short post every other day.