Feb 01

Print this Post

Was Steve Souders wrong?


Wow, it’s been a while again. Sorry about that but the end of December and entire January were really busy for me. The fact I had 6 updates waiting in my WordPress dashboard just proves more how long I didn’t visit this page. Nothing changes about me having no time for anything…

The same is with this post. I decided to write it because I can’t wait till I finish the book, I’m reading. I’m sure most of you know it. It’s a quite old book if we’re talking about computer books. High Performance Web Sites by Steve Souders. The book isn’t a big one as Thinking in Java, Thinking in C++ or any other thinking-in-a-computer-language books. But I started reading it on Monday, I read about half of it and didn’t find time to finish it yesterday… and probably today. So, I decided to write about at least the half I’ve managed to read this month. I’d like to write a summary after I finish the book — it’ll be probably mostly for me because I’m almost the only reader of this blog ;) And I’m sure while writing I’ll remember more from what I’ve read.

So, the summary will show up here but today I’d like to write about two chapters I’ve already read. The book is mostly dedicated to frontend engineers and it explains how important is to think about performance of your website when you’re a frontend developer. But among the chapters at the beginning the author forgets about it and, in my opinion, at least two of those chapters are addressed to web application server’s (Apache) administrators.

Rule 3: Add an Expires header

Thanks to such a simple solution our page could be 50% faster (if a user let her browser cache pages — by default most of the browsers do that). But, how do HTTP headers sent to the server link to a frontend engineer work? As examples Steve Souders gives us three lines of Apache server configuration (with mod_expires module enabled):

<filesmatch "\.(gif|jpg|js|css)$">
ExpiresDefault "access plus 10 years"

How simple is that?! Piece of cake! But what I’d like to add is that many of common frameworks gives you ability to add the headers. It can be helpful when you don’t have access to your server configuration because you use one of different hosting services. But it won’t add the header to your gif/jpg/js/css files — only the php output will have the header.

[important]So, remember: Add a far future Expires header to your components.[/important]

Rule 4: Gzip Components.

Again, from his tests Steve Souders has interesting results — with sites loading faster of around 50% and size reduction of 70%! And again, this time he presents us two Apache modules: mod_gzip and mod_deflate. The first one is available in version 1.3 and the second one starts with version 2.0. And the basic configuration for compressing scripts can’t be easier in the second case:

AddOutputFilterByType DEFLATE text/html text/css application-x-javascript

With mod_gzip in Apache 1.3 it takes few more lines:

mod_gzip_item_include     file     \.js$
mod_gzip_item_include     mime     ^application/x-javascript$
mod_gzip_item_include     file     \.css$
mod_gzip_item_include     mime     ^text/css$

Of course before that we have to put the directives which enables the module and it’s nice to put there also additional directives and have better control on the configuration. Since, as you probably know, compression is quite CPU consuming and we need to find the optimal way of using it.

Again, there are PHP frameworks which helps you with the compression of response.

[important]So, remember: Gzip your scripts and stylesheets.[/important]

Was Steve Souders wrong?

Was he wrong and instead of 14 steps for frontend engineers there should be 12 steps? Of course no! Recently someone sent me a link to an article about problem of finding out why your agile team isn’t agile at all. The main reason was that only one part of a project is being created by one agile team and after “their work” the other part of the project is being made by other agile team. When, there should be one team with at least one specialist of a domain. Sometimes, especially in small companies, this is hard to do. But there is also the idea we need to improve ourselves all the time ;) So, if a frontend developer has a little knowledge of configuration of an Apache server, that’s good! (at least better than no such a knowledge at all)

Permanent link to this article: http://blog.lukaszewski.it/2012/02/01/was-steve-souders-wrong/

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>