AJAX is the current buzzword these days… no doubt about that. To learn to program AJAX, is like mall roaming teenagers trying to get the latest piece of accessories to make them look hip and cool… That is, as there is nothing really cool about the piece of stuff, but you will look cool wearing it because everybody will say so…
No different with AJAX, since there is nothing new in the technology, just good old Javascript plus some ingenuity on using dormant browser feature, then you get a whole new buzzword, which in turn, if you can do it well enough, will raise your self esteem among your fellow programmers, or maybe raise in salary or fee since now you can say “I can do AJAX too” to you boss or your client.
From user perpective, no one cares… all user see is that now they can click on your website and the information pops up quickly, without having to wait for the page to reload. What does it mean for them ? You may say, better user experience. But, be aware, user comes from all walk of life, meaning, they access your site using many different kind of browsers, devices, and don’t forget, many different levels of infrastructure capacity and capability.
Internet users still varies greatly these days, even with all broadband, wireless whatever technologies.. major portion of the world is still using dial up, yes it is true, and believe it or not, old OS like Win95 is still alive in many many places, meaning IE5 is still around ( yeah, bad enough to have IE around, let alone the old one )
I’m not exaggerating things here, because this is what happen in my country. I once had a shocked overseas client when I told him I had to switch to dial up connection because he broadband connection went down.
Ok, regarding the title above, in my opinion, a good developer should be aware of everything above mentioned. Developers rarely concern about accesibility, many of us simply trying to create “cool” stuff, create the next Facebook, or Google, or WhateverCoolToday sites, then after that wonders, why there’s only a few people visiting, let alone registering and become returning user ? When that day comes, look back at your codes, don’t look at marketing people, at least, recheck your codes before you throw flames at marketing
What does these have anything to do with AJAX ? AJAX is cool , and it provide better user experience isn’t it ? Hmmm… AJAX put more strain to the server than ever before. that’s one for a start. Back in the days, a hit means one user accessing one url, or one web page, if she stays for 10 minutes on the same page, doesn’t really matter because no request sent to server during that 10 minutes ( well sort of …). These days, take example of a page with autoupdating AJAX widget, when a user access it , read that page for the same 10 minutes, she wouldn’t even realize that during that 10 minutes of her visit, her browser has sent hundreds of request, AJAX request or XHR if you prefer geekier term. Put more variables into the situation, let’s say, her PC is a rather old Pentium 3 laptop, with bundled Windows2000 and yet to be upgraded IE5.5 … She connect to the internet using 50kbps residential shared broadband connection, on peak hour which only give her only a portion of the term “broadband”… chances are she won’t even stay for 10 minutes, but if she survived, then that will become a strain on her PC too.
Think about this when developing web application in general, not just when being cool developing AJAX. Good developer do test, meaning, not just testing for the functionality and reducing bugs, but also test in every condition possible. Remember, you develop for user, not just for your personal enjoyment ( but if that the case, then good for you, you may scrap all my blurb here ). In my experience, you can throw anything you want to the user, they will grab it instantly, but on the other hand, they are smart enough not to swallow everything, and when it happens, they simply move on and forget about your site entirely.
Other thing is mash ups and APIs… I personally like the concept of sharing with the world for the better, but I never understand how one can build a business out of somebody else’s application API. How realiable could it be for the user ? Fine if the API come from Yahoo, Google or the glorious Facebook, but what about so many more that provides API because they want their application to grow bigger, not because they think their application is usable, unique and people really demand API to get connected ? reliability is the main concern here. Just take example of pre Ajax mash ups, the banner exchange… nothing too smart about exchanging banner, but when a website has too many different affiliates, with different infrastructures, and different server loads, it will become hell for the user because pages will load with random and somewhat significant speed difference, and hell for the developer to figure out which affiliate link cause the problem. Things get worst when banner exchange start to use javascript, which is NOT threaded, therefore, it will be executed in blocking sequence, and once it stuck on one affiliate code, it will attemp to finish that block of code first before moving on to another block. If it stuck forever, you’ll get crashed browser, or simply half complete page staring at you.
Okay, no worry.. I do believe in progress, and I also believe that technology will solve it’s own problem, but in the mean time, there’s nothing wrong with becoming developer with conscience. A developer with good understanding on what user will need and use, rather than developing something too advanced and too sophisticated that will defeat it’s own usability.
I’ve been wondering for a while if I can do automatic subdomain using username, same as Wordpress MU does. Some thought come across and all leads to same point , the $base_url() variable.
What makes me a bit wary is that particular variable reside in config file, which suppose to be static. On the other hand, manipulating the variable in controller is easy but redundant. So what the heck…
There are three places to modify for this :
Life has been good to me since I have full control over those three, I have my own DNS server, and apache server, so if you are less fortunate than I am, do not hesitate to nag , beg and annoy your hosting company to do changes for you
DNS entry :
make sure you put wildcard entry :
mygreatsite.com. A 123.123.123.001
*.mygreatsite.com. A 123.123.123.001
Apache vhost :
We use separate vhost file for each domain, and include those files using Apache “Include” directive, to keep things tidy and avoid fiddling with main apache config.
<virtualhost>
ServerName mygreatsite.com
ServerAlias *.mygreatsite.com
ServerAdmin superduperadmin@superduperwebcompany.com
#RedirectMatch 301 (.*) http://mygreatsite.com$1
DocumentRoot /var/oi/keepcodeigniterhere
<directory>
Options Indexes FollowSymLinks MultiViews
</directory>
AllowOverride All
Order allow,deny
allow from all
</virtualhost>
the most important part is :
#RedirectMatch 301 (.*) http://mygreatsite.com$1
CodeIgniter config.php :
I test using this simple hack ( on the config.php ) :
$config['base_url'] = "http://".$_SERVER["HTTP_HOST"];
And wala !! I can test using whatever.mygreatsite.com and codeigniter still working as if there is nothing wrong with $base_url variable, therefore you can use any words ( hence, wildcard ) as subdomain prefix and apache will direct the request to the same codeigniter installation. Next step I will do is using username as subdomain, eliminating ugly url like
http://www.mygreatsite.com/someuser/profile
and make it nicer as in
http://someuser.mygreatsite.com/profile
Nice !!
Yeah I know I have to test rigorously to ensure nothing is broken with codeigniter ( and my application ) but at this moment I think it leads to the right direction.
I also do some search at CodeIgniter’s forum just to verify my method and I’ve found great reference :
http://codeigniter.com/forums/viewthread/51627/
For wildcard DNS, take a look at this guide by Wordpress creator :
http://photomatt.net/2003/10/10/wildcard-dns-and-sub-domains/
from those forum entry, I’ve made final modification to the config.php file :
$config['base_url'] = "http://".$_SERVER["HTTP_HOST"];
// provide easy to access variables for the rest of the application
$usernamehost = explode('.', $_SERVER['HTTP_HOST'], 2);
$config['tld_base_url'] = $usernamehost[1]; // contains "domain.com"
$config['user_base_url'] = $usernamehost[0]; // contains "sub"
Hopefully this will work as expected , and also useful to anybody who wants to achieve similar thing.
Just a twitch in my brain :