How to speed up your site(Part 1)

How to speed up your site(Part 1)

One of the most important things about running a website is having low loading times.

Why?

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.

How?

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.

Browser Caching

This is also really easy to set up, and can have huge performance benefits for visitors(after the first page load). Even if you run a blog where you post daily, there are still a lot of resources that don’t change that often, such as images, JavaScript, and CSS. Browser caching is basically telling your visitor’s browser to store those files locally for minutes, hours, days, weeks, etc., so the next time they’re requested, the browser has the files available and does not need to make another HTTP request. This also decreases load on your server as less requests have to be made, because a large portion will be cached on the visitor’s computer.

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.

Minification

Minification is basically taking all the parts out of your website that aren’t needed to make it function. When writing the HTML, Stylesheets, or JavaScript of a website, many developers will make newlines and comments to make the code easier to understand and update. The problem with this is that all the comments and newlines take up space, and increase the amount of information the server has to send, increasing page load time. And, comments and newlines are not needed by the browser to understand how to render the page.

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

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.

Sources: Impact

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.

Leave a Reply(Markdown is On)

%d bloggers like this: