What Is Content-Encoding On Your Webserver?

 

Content-Encoding can dramatically increase the speed of your server. I’ll show you how to check to see if it’s turned on, and help you understand how to communicate with your host about what you need.


This tip was sponsored by OSTraining.com! OSTraining aims to explain websites so clearly that anyone can understand, with jargon-free, hands-on training that clearly defines processes to simplify complex tasks. OSTraining offers online courses, best-selling books, onsite training, and online live training.

More than 100,000 students have learned website development through OSTraining. OSTraining courses focus on web development and the tools around it, including WordPress, WooCommerce, Drupal, Magento, and Joomla.


Transcription

Hey folks, welcome to another HeroPress Tip of the Week. This week, I’m going to introduce you to several different terms, those being HTTP compression, Content-Encoding, and gzip. And I will tell you what they mean and why they matter to you.

HTTP is the protocol that the web uses to move webpages around Hypertext Transfer Protocol. And compression is exactly what it sounds like. It’s shrinking it, it’s making it smaller. You may be familiar with zip files on the web plugins and themes are in zip files. And in addition to putting a bunch of files together into one file, they also compress it and make all of these files smaller than they would be if they were all individual. The web has the ability to do that same kind of compression and make webpages much smaller. So let’s take a look at how that works.

Right here are some headers that your browser sends out to the server when it’s saying I would like that web page, please. So you type in a URL. And it sends along accept info encoding. And it lists all the kinds that the browser itself can handle. In this case, it’s G, zip, and deflate. The server gets that and says, Okay, I’m going to send that file back. Oh, but look, they accept gzip. And I know how to do gzip. So I’m going to gzip my file before I send it back. And they send it out, and the browser receives it and says I recognize gzip and unpacks it and displays it for you. All this happens without you even knowing it. You don’t have to do anything to make it happen. It just happens. But it can make your webpages dramatically smaller in transmission, which can then therefore, greatly increase your speed. So that’s HTTP compression, and Content-Encoding, except encoding is what the browser says sends Content-Encoding is what the server sends back. But what is the stuff? Let’s take a look at here at gzip.

I mentioned zip files, which can hold multiple files inside and then compress them. The difference with zip is that it doesn’t do multiple files, it does only one and it only compresses. If you want to do multiple files, you can combine it with some other program like tar, you may have seen a tar gz file. Well, gzip just compresses. And it has several advantages over the kind of zipped that you’re used to. One is that it is extraordinarily fast, which needs to be in a browser situation. And it does a better job of compressing and making smaller files than zipped does. You can use gzip anywhere you can use it on your Mac, your Windows machine or anything. But in this case, we’re looking at it just with HTTP compression. So then, I want to show you how to tell if your server can serve it is serving it, et cetera. Recently, we did a tip of the week on curl. And we looked at using dash eye to look at headers. Well, you can also send headers, just like we were showing you in on the Wikipedia page. And then the server will send back what it can handle. So I’m going to copy the first part of this and then paste it here and put it in your wordpress.com shall any HTTPS and there we have right there Content-Encoding: gzip.

Let’s try a couple others. There’s wordpress.org and gzip. It works. gzip is actually on most servers these days. I’m showing you so that you can check in if it’s not there. Then you can go to your host and say hey, we need this or maybe choose a different host easter egg I wanted to show you wordpress.org sends an Easter egg header called Hold off at its snowman. There is another type of compression that is becoming more and more common, and that’s called B R. So let me show you what that looks like. We say that we can handle the R, then then right back Content-Encoding br, there are fewer of them that can handle br than cheese. gzip is pretty universal, br is less. So however, br Does better compression. So it’s quickly becoming very common. So I want to show you what gzip actually does. So if we do curl, here, or press.com, it’s going to get the page and just spit it out on the screen here. What we really want is to have it in a file. So we’re gonna go like this hero, press dot HTML.

So we do a long listing with showing all information as much as possible with H for human readable. So the here first page is 157k. So I’m going to make a copy of that. So there we have two of them. And they’re both 157k. So now I’m going to gzip your first html.

Now, you can see that the gzip version is only 31 kilobytes, as opposed to 157. Because I’m bad at math, I found this cool calculator. And the compressed version is 76% smaller.

Now imagine you can do that for all of your web pages. Keep in mind, we’re only doing this for HTML at the moment. But imagine all your HTML pages being 76%. Smaller, that greatly greatly reduces the amount of traffic you’re sending. It makes it much much faster. There’s just there’s no downside to this. And the difference is dramatic. So my point of this whole video is that you check your own site. And you can do that. Just like this. I’ll put this in the video comments. And if you don’t have it, ask your server or your your hosts to turn it on. Or maybe you need a different host because it’s a big deal. I hope you find this useful.