Archive for the ‘development’ Category

PHP caching and APC

October 9th, 2009 | development, php, www | No Comments

A friend asked me recently about the caching options available to him with PHP on a linux stack. While he had looked into memcached and seen the difference it can make, he had overlooked APC.

APC, or Alternative PHP Cache, not only allows for faster pages through opcode caching, but also since v3.0.0, allows for users to store any kind of data in memory for access between and across all requests. See my example below for a better idea on how to use it.

/* The first argument is the unique key which
 you will use to store some data later.
For globally cached data, the URL could make a good key,
and you could append the user id for user specific data.
The second argument is set to true or false depending
on whether APC finds data at the location,
if we don't find it, we know we need
to (re)generate it. */

$html = apc_fetch("unique_key_url", $success);
if(!$success)
{
	$html = big_and_slow_function();

	/*here the first argument is the key again,
	followed by the data to store and
	finally the time to live period in seconds */

	apc_add("unique_key_url", $html, 180);
}
echo $html;

Using a mechanism like this, you can see massive decreases in page load times. The friend I mentioned earlier brought his front page load time down from a number of seconds to low milliseconds.

Pushup ? browser update notifier

August 13th, 2008 | development, itunes, www | 1 Comment


Every developer out there is sick to death of the mostrosity that is IE6. As part of a movement to “push” users up from out-dated browsers, pushup is a little script to automatically notify those users and provide them with a link to update their browser.

If you’ve visited this site on an older browser (extremely few do), you would aready have received a notification for this ;)

Using Amazon S3 for backups

August 6th, 2008 | development, php, www | No Comments

It became clear early on in the planning stages of our current project that we were going to need a reliable backup solution. We discussed backing up to another server we already have in the datacenter and backing up to a server in another datacenter. The former was not redundant enough for our liking and the latter would introduce extra costs we could do without so early on.

Enter Amazon S3. You pay for as little as you need and it expands as you do. The S3 docs point to undesigned’s PHP5 library using cURL. Perfect. 15 minutes and about 10 lines of code later we were archiving and backing up user content to S3.

About

A Web Developer by nature and by trade. Living in Dublin, Ireland and working at Web Reservations International. Has a passion for LAMP, XHTML/CSS, JavaScript and playing with the latest trends in technology.