Tim Igoe's Web Design, Development and Hosting Blog

Saturday February 6th

Understanding Web Statistics

Web statistics are a very important part of web site development and
marketing.  Every day you collect statistics for, you are gathering
valuable information to use in your marketing strategy. There is
nothing better than looking at a document full of graphs showing
increases in users or traffic; however, reading them and understanding
how to use them effectively are two very different things.

To read the full article, please go to http://blog.jellymedia.com/2010/02/05/understanding-web-stats/

Wednesday February 3rd

Thoughts on Facebook's HipHop for PHP

Yesterday Facebook answered rumors and announced their HipHop "compiler" for PHP project. http://developers.facebook.com/news.php?blog=1&story=358

Facebook describe it as a source code transformer and has allowed Facebook to massively increase the operational speed of the PHP elements of the site. HipHop gains its performance by taking the PHP and converting it into C++, this C++ can then be compiled into more efficient machine code.

Interpreted scripting languages, like PHP, are brilliant for developing because they are simple to learn and easy to debug but being interpreted they have the major disadvantage of poor performance. Every time a script is run, it is first compiled into 'opcode', a half step between the raw PHP and a form of machine code. This is then interpreted by the PHP runtime. Currently, there are a few opcode caching systems in existance, APC, eAccelerator and xCache all cache the opcode each time the PHP scripts change to speed up the process of executing the scripts.

HipHop goes one step further, and converts the PHP into C++ that can be compiled into machine code itself, but to do this the Facebook developers have decided to sacrifice "some rarely used features -- such as eval()". A very important question here is what have they decided are rarely used features and what have they dropped support for.

Dropping features changes the language itself and to use this new "language", you'd have to be well aware of what is missing and work around it, it isn't just as simple as looking at the PHP documentation and knowing you've got access to everything there.

Currently, Facebook haven't actually released the source code, however I am still interested to see how it works but currently I know I cannot use it due to various requirements for eval() in, for example, my plugin system and the vBulletin forums.

Friday January 8th

Forcing www. via .htaccess

If, like me, you often set your servers up to allow traffic to your sites from both domain.com and www.domain.com but would rather users only used one, there is a simple way to achieve this with Apache and mod-rewrite.

Putting the following in a file called .htaccess within the root of your website, you can achieve this automatic redirection to www. with little effort and no need for code to perform the check.

.htaccess


RewriteEngine  on

RewriteBase   /

RewriteCond %{HTTP_HOST} !^(www.|$) [NC]
RewriteRule ^ http://www.% {HTTP_HOST}%{REQUEST_URI} [L,R=301]


This code, checks the current HTTP_HOST the user is viewing, so if they were to come via domain.com for an example, it would check to see if the host starts www., this case it doesn't so it would do a 301 redirect to the same URL, but corrected to include www.

Nice and simple, but very useful.