knightly

Monthly Archives: February 2009

ElePHPants

Good thing i sometimes use my wife’s computer for backup. I found my lost pictures again :) Say hi to my blue family.

img_1364

img_1365

img_1372

Speed up and save traffic with Apache and mod_deflate

One of our sites was loading pretty slow. This is mostly caused by a very heavy design. But i still wanted to speed things up a bit.

The first step was compressing all JavaScript files with the Yahoo YUI compressor. The next step was to activate mod_deflate and compress all text, XML, and media files (JavaScript, CSS).

When the mod_deflate module is loaded in apache this is a pretty easy thing to do. Just add the following lines to a .htaccess file in the root of the web site / application.

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

The first line enables mod_deflate for the specified extensions. And the other three lines are there because of the way some older browsers handle gzipped data.

To test if the the content is transmitted over the line in gzipped format i used the Live HTTP Header Firefox extensions. This let’s you watch the Live HTTP headers as the fly by.

Check the HTTP/ 1.x 200 OK response from the webserver for the following line

Content-Encoding: gzip

And to test what happens if a browser doesn’t support gzipped data. You can set a configuration parameter in Firefox about:config.

gzip, deflate enabled:

network.http.accept-encoding = gzip,deflate

gzip, deflate disabled:

network.http.accept-encoding =

References :
http://www.howtoforge.com/apache2_mod_deflate

elePHPants

Some time ago i got a truck load of elePHPants [1] [2]. Thanks to Damien from Nexen. I wanted ti post the picture with two hundred of them sitting on our couch. But seems i lost some pictures with my last disk crash. This is the only only one left.

double_tail

Zend Server Community Edition Beta!

This week Zend released a Beta version of the new Zend Server and Zend Zerver CE (Community Edition). So last night i couldn’t sleep and decided to take a look at the CE version of the two.

Zend Server CE
The package is a nice stack of applications / components that build up a solid PHP development environment. The package consists of the following main parts. And of course some 3rd party libraries to support the PHP extensions.

PHP v5.2.8
Apache v2.2.10
Zend Data Cache v4.0.32
Zend Debugger v5.2.17
Zend Guard Loader v3.3.5
Zend Java Bridge v3.1.21
Zend Optimizer+ v4.0.27
Zend Framework v1.7.4

Like i said it’s a great stack of applications and components that gives you a solid PHP development environment up and running in seconds. On top of that it provides the nice looking web GUI in which you can easily configure most of the suite. It’s a breeze to activate or deactivate PHP extensions and Zend components. And almost all PHP ini settings can be configured here as well. There’s some logging functionality that’s always handy.

Although it would have been nice if there would be some way to configure the web server from the interface as well. And maybe some integration with PEAR? It would have been nice if the web interface had some configuration options for Apache and PEAR as well. But besides that. I like the package and think Zend did a great job on this one. The application is pretty self explanatory so i will not spend more words on it. Besides Zend did a great job at documenting it all.

http://www.zend.com/en/products/server/getting-started/?zsp=gettingstarted
http://files.zend.com/help/Zend-Server/zend-server.htm

Below i posted some screen shots of Zend Server CE in action:

Zend Server Dashboard

Zend Server Dashboard

After logging in we are greeted with a nice dashboard screen. That provides shortcuts to the rest of the application.

Zend Server info

Zend Server info

The Server info page shows everything running under the hood of Zend Server CE.

Zend Server PHP extensions

Zend Server PHP extensions

Zend Server turn off extensions

Zend Server turn off extensions

Configuring and activating or deactivating PHP extension sis a breeze.

Zend Server application components

Zend Server application components

Zend Server turn off components

Zend Server turn off components

The same counts for the Zend components which can be configured and activated or deactivated at will.

Zend Server PHP directives

Zend Server PHP directives

Configuring PHP ini settings has never been this easy

Search indexing and duplicate content

Over the last few days i have been reading my mind dumb about SEO techniques. En specially how to eliminate duplicate content. For the main part this is all clear. And we succeed in implementing most SEO techniques without problems. One question however remains. Even after reading through Matt Cutts complete website :)

So maybe some bright mind could shed a light on the following situation.

We have two domains for example a.nl and a.be. Two separate domains that point to the same website. Just because people in Belgium would probably feel more confident buying something from a local website then one based in an other country. But the content under both domains is identical. The reason behind this is. In Belgium (.be) and The Netherlands (.nl) people speak Dutch. So there’s not really an option in providing content in a different language.

Now the question does Google or any other search engine see this as duplicate content? And if yes what can be done about it. My thought was to add 301 responses to the .be site and do everything over the .nl site. But this would render .be useless in my opinion.

301 Redirect losing POST data

Earlier this week i implemented the forcing of trailing slashes for some websites. And this worked out great.
But today one of the ladies here at the office noticed the contact form on one site wasn’t functioning properly anymore.

So i did some debugging and quickly came to the conclusion the POST data array was empty after a submit of the form. That’s weird i thought. And didn’t really have a clue where to start looking. The code wasn’t touched for a couple of weeks. Bu then i remembered adding the forcing of the trailing slash.

So i browsed to the contact form and did a view source. And there was the problem. The form submitted to

/contact/verstuurd

A URL without a trailing slash. This causes apache to rewrite the url to

/contact/verstuurd/

And this also seems to turn the POST into a GET request.

So to fix it just changed to URL in the form to reflect the correct end point. But i have to say i didn’t expect this to happen. I understand why it happens. And it’s pretty logical. But i wonder if there’s a way around this behavior?

Forcing a trailing slash with mod_rewrite

I’m doing some SEO optimization for a couple of websites. And one of the small steps is to force a trailing slash on all URL’s that do not point to a file on the server. The reason I’m doing this is to go around the duplicate content problem.

/trip/80
/trip/80/

Both point to the same content. But a crawler would see this as two different URL’s. Which off course is correct. But this can lead to duplicate content being indexed in search engines. Which could result in penalties for the site in question. So to fix this problem we add three simple lines to the main .htaccess file

# If a requested file does not exists
RewriteCond %{REQUEST_FILENAME} !-f

# If a requested directory does not exist
RewriteCond %{REQUEST_FILENAME} !-d

# Force a trailing slash to the request
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]

New INI’s for PHP

Every morning i browse through the messages on php.internals. To keep me up to date with what happens under the PHP hood. It’s great stuff to learn about new features. Today one of the posts caught my attention. Titled ‘New INI’s for PHP‘. The post provides a URL to the PHP wiki page.

It’s still a proposal. But as i read it. The php.ini file will be separated into two files. One for development and one for production. The first thing that crossed my mind was. Cool! I can test my production code without uploading. I just change the ini. But does this really make sense?

When i build a web application. I keep all the settings and configurations inside of the application. The framework i use makes it easy to switch between development and production. The way i look at it this should not be done on PHP level. But rather on application level.

Google earth libcrypto crash

I was reading up on some new features the guys at google pushed into google-earth. And i was curious enough to give it a try. So i downloaded the installer for Linux and installed the application without any errors. But when i tried launching it from a command line. I was surprised to see the application crash and burn with the following message:

Warning: Unable to create prefs directory ‘/home/user/.googleearth’. File exists.
./googleearth-bin: relocation error: /usr/lib/i686/cmov/libssl.so.0.9.8: symbol BIO_test_flags, version OPENSSL_0.9.8 not defined in file libcrypto.so.0.9.8 with link time reference

Seems the libcrypto.so is linked against some wrong libraries. Thankfully this is pretty easy to fix. Just browse to the google-earth install directory and run the following commands:

$ rm libcrypto.so.0.9.8
$ ln -s /usr/lib/libcrypto.so libcrypto.so.0.9.8

The main reason i installed google-earth was to check out the new ocean view feature. So i selected a piece of coastline near the Netherlands.

nl_coast

Although i was looking for some ocean life. The first thing i found was an airplane :)

plane

Stop ACTA