What if I told you that two lines of code could wipe a significant chunk off your page load speed and speed up every page on your website? I’d have your attention right? Everyone wants their website pages to load fast. It’s good for visitors. Therefore it’s good for business. It’s good for Google, which penalises slow loading sites. Therefore it’s good for business. There are vast numbers of online guides showing, in huge intricate detail, how to decrease page load time. Just reading them takes time and effort and then implementing the advice takes more time and effort. On top of that time and effort, there’s money, because using a decent web server is fundamental. However, there’s something that I never see mentioned in any of these guides and it relates to sites that are using https with an encryption certificate. So if that’s your site read on, and if you aren’t using it, then read my guide showing why you should be using https.

Here’s the GTMetrix waterfall report for my site before the change:

Before speed up https page load hack

Notice the half a second (508ms) attempt to render that HTTP version of the site before doing a 301 redirect (the top row)? That’s what I’m going to eliminate.

Here’s the same report, but after the change:

After speed up https page load hack

Half a second saved! Which is about 20% of my total page load time.

If you tested your site and it does that HTTP rendering step, then here’s the magic:

Apache webserver

Edit or create your .htaccess file (found in the root folder of your website) and look for a line that says: “RewriteEngine On”

Just after that, paste the following code, but MODIFY THE URL TO MATCH YOURS, otherwise your site will immediately break!

# force SSL (remember to change site address below)
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]

OK, yeah, that’s 3 lines of code, but the first line is just a comment. If the “RewriteEngine On” bit isn’t there already, add that just in front of it too.

Nginx webserver

Edit your Nginx config file (e.g. nginx.conf)

Add this before anything else that looks like redirects:

# force ssl (remember to change site address below)
server {
  listen [::]:80;
  listen 80;
  server_name yourdomain.com www.yourdomain.com;
  return 301 https://www.yourdomain.com$request_uri;

A couple more lines of code, but same result. If you are using the Nginx panel for cPanel, there is a button to enable this.

Any time you share a link to your site, you should be specifying the https version, but for people that are typing in the URL manually, or people clicking old backlinks before you ever had https, then this will speed up the pageload for those visitors.

Please test changes like this thoroughly before assuming what works for me will work for you.

Previous post
Previous post
What should you expect from a new website? As well…

Pin It on Pinterest