Phelio Gnomi

My words from my mind

Category Archives: Web Tools

Methods of getting direct feedback from Servers

With the web technology advancing so rapidly and information is getting bigger and flowing faster than ever, many web applications nowadays can’t live without constantly checking for new data from the servers.

The most basic form of a websites deals with HTTP request from the webpage to the server. The user send a request in an url form and the server response with the content that was requested. End of story.

Say that you are viewing a page that tell you how many times a jumping sheep has been jumping and it is jumping in average of once every 1 – 10 minutes, you might want to refresh your page every few minutes if it has been jumping or not. But with today’s technology, there should be a way that we get notified whenever the sheep jumps.

The main challenges of getting a direct feedback is that web application usually support a huge amount of users and they could be located anywhere in the world. It is simpler to think that the server just give the information whenever it’s requested. Instead of being busy trying to send updates to every connected clients (if they are connected). However, let’s explore the possible implementations.

Auto refresh

If you’re building a website in the 1990s, this is probably a very viable options. It’s simple to implement and logically sounds. The requirement is simple, you need to know when the sheep in your server jump, but the server is not capable of getting to you and every one of you. So we set up a simple Javascript to auto refresh the page every few seconds.

The drawback is, page refresh is rarely favourable in the fast moving content packed web applications. By refreshing the page, you will need to refresh other resources needed where we are only interested in a simple integer that tell us if the Sheep has jumped. So, let’s move on.

Ajax Long Pooling

Ajax open up many great possibilities that until this day has become one of the core protocol in building responsive web applications. With Ajax, we can send a request without refreshing the page. This also enable us to implement a much more efficient auto refresh that doesn’t request the full page request. Instead, we send a smaller HTTP request in the background and update the page using Javascript.

In addition to that, we can set the connection to stay alive until we get a response (or time out). Anyhow, this will still involve the web browser to constantly sending new requests every now and then to get updated. One drawback is that the server might be idle for few hours without any new worthy updates, so the resources used to send those requests might just end up in waste.

Web Sockets / Comet / Probably other terms

lastly we have web sockets. With the web servers and browsers needing more and more frequents interaction, there is finally a way that the server can be event driven instead of request driven only.

Web Sockets allow a more interaction connection where the server can be allowed to send response based on events that happens in the server itself. In this way, the web browser (client) doesn’t have to constantly send request for updates, but simply be event driven as well that only reacts when needed.

This will also reduce the overhead of constant new requests that happen between the client and server.

However, web sockets may cause some compatibility issues depending on the server technologies used and also the browser. But we’ve seen an increasing support for this technologies that allow developers to create more and more responsive applications.

One popular technology that works well with Web Sockets is Node.JS. But there are ways to work around Django through Redis or other library that can provide us with this capability.

Advertisements

Back to Yii

I finally solved the problem with the Selenium testing. The problem wasn’t because of the “Failed opening ‘SiteTest: Firefox.php’” at all. It was just a warning message. The real problem is the curl extension in PHP. I thought I already enabled it, but not when the CLI version is not using the same ini file. So, after I enable the curl in the CLI version of the ini file, it works fine.

I’m still wondering though, how do I make the CLI version use the same ini as the web version.

I wish that I’m done with Yii

No offence Yii, but I’m going to move on. First, your lack of examples in your user manual – where the the manual itself is mediocre to start with – is tolerable. But, I started to wonder if people really use you. For a tool like you, you should be proud if people talk a lot about you, especially best if they talks about the problems they are having with you. At least by then, there will be lots of devoted worshipper that are willing to find the solutions for every problem that people talk about.

I just can’t do it any more. I’m stuck here with a problem that nobody (that I can reach) knows. It all started with one very promising book “Agile Web Application Sevelopment with Yii 1.1 and PHP5” which is really good to start with. But it only take 3 chapters for you to left me bleeding at a corn field near my uncle Jimmy’s house. I’m still bleeding by the way, just so you know. I just can’t figure out how to make the Selenium works without giving me that “Failed opening ‘SiteTest: Firefox.php'”error. I can’t proceed without Selenium, the whole book is about Test-driven approach. And if the testing tools doesn’t work, how to proceed?

There are still plenty of fishes in the sea. Though you are the chosen one and I have to come back to you one day, I think I’ll just forget about you until then.

jQuery: It’s Easy to Create Websites Nowadays

I used to be proud of being a programmer. But now, given that things are a lot easier with jQuery, I feels that I’m not more than a Web Designer. Not to say that web designers are not cool, they are superb in their graphical creativity, which I’m lack of.

Friend: So, what exactly do you do at work?

Me: I create functionality for websites.

Friend: is it hard?

Me: not at all. In fact, I can teach you some cool tricks. You can just put something like $(“#banner”).slideDown(); and the banner will slide down.

But from the other point of view, jQuery has bring me to a much a higher level excitement. From a web developer that only care of back-end processes (that I can be proud of, but nobody really care) to somebody that is willing to improve website experience (that more people will “WOW”).

Tracking Your Website Visitors

If you are running a website, and you want to know how many visitors are there, google/analytics is the answer. I use it even in my first blog I ever created 4 years ago and it’s really worth using it.

This tool will show you the numbers of visitors by days. It also tell you where are they coming from, how they ended up in your site, and how long they stay in your site. There are many more functions that you can explore yourself.

First, you kind of need a google account. Register one if you don’t have. Once you have a google account, you will have access to many other tools like gmail and adsense (which is one of the tools for your affiliate marketing).

After that, you will need to put a tracking codes in your website. Analytics will guide you how. You might need to wait for few hours or days before you can start seeing the tracking result. So, have fun and be patient.

Some blogging system might already provide you with its own tracking system. For example wordpress.com, it has its own site statistic that show you about the same information that analytics gives.