prenagha is currently certified at Apprentice level.

Member since: 1999-11-23 22:56:24
Last Login: 2011-06-17 00:59:28

FOAF RDF Share This

No personal information is available.


Recent blog entries by prenagha

Syndication: RSS 2.0

Diary/blog now on my home page courtesy of Personal Weblog.
Read it there if you like.
Subscribe to the mailing list to get new entries via email if you prefer.
Or ignore it entirely.

Worked out a server-side caching mechanism for PHP based sites. This is extremely helpful to performance. Somewhat like the concept of a reverse-cache sitting in front of a webserver, like squid, but this can be used on those hosts that don't have that software installed. Here is a snapshot of the PHP code, usage should be self-explanatory. I just started testing it, but so far so good.

function pageCacheStart($ttl=600, $debug=FALSE, 
  $cacheDir='/tmp/pagecache', $sidName='psid') {

//to force the cache OFF, uncomment next line //return FALSE;

// we only use the cache for GET requests. // we don't use the cache for ssl requests. if ($HTTP_SERVER_VARS['REQUEST_METHOD']!='GET' || isset($HTTP_SERVER_VARS['HTTPS']) ) { return FALSE; }


// if we have the sid in the get vars, // and we have the sid in the cookie vars, // then we can act as if the sid is not in the get // vars and return a cached page. // if the sid is in the get, and not as a cookie, // then we don't use a cached version since all the URLs // in the page need to be rewritten with the sid by php. if (isset($HTTP_GET_VARS[$sidName])) { if (isset($HTTP_COOKIE_VARS[$sidName])) { if (count($HTTP_GET_VARS)==1) { $REQUEST_URI = $HTTP_SERVER_VARS['SCRIPT_NAME']; } else { $REQUEST_URI = ereg_replace('&'.$sidName.'=.{32}','',$REQUEST_URI); } } else { return FALSE; } }

// get the hostname if (isset($HTTP_SERVER_VARS['HTTP_HOST'])) { $HOST = $HTTP_SERVER_VARS['HTTP_HOST']; } else { $HOST = $HTTP_SERVER_VARS['SERVER_NAME']; }

// cache directory use for pages from this host. $cacheDirHost = $cacheDir.'/'.strtolower($HOST);

// build the name of the cache file for this page $cacheFile = $cacheDirHost.'/'.md5($REQUEST_URI).'.cache';

$mtime = filemtime($cacheFile); $time = time();

if ($mtime >= ($time - $ttl)) {

//send cache control headers that let client browser //cache the page. header('Expires: '.gmdate('D, d M Y H:i:s', $time + $ttl).' GMT'); header('Last-Modified: '.gmdate('D, d M Y H:i:s', $mtime).' GMT'); header('Cache-Control: public'); header('Cache-Control: max-age='.$ttl);

//get the cached file and send it to the browser immediately readfile($cacheFile);

//debug info if ($debug) { print("<hr>CACHED COPY
filename: $cacheFile\n"); print("
mtime: ".date('m/d/y h:i:s a',filemtime($cacheFile))."\n"); print("
cache age ".(time()-filemtime($cacheFile))." seconds\n"); }

//exit this server session exit();

} else { // the directory existence is the signal that pages // from this host should be cached. if (!is_dir($cacheDirHost)) { return FALSE; }

ob_start(); print("<!-- request: ".$HOST.$REQUEST_URI." -->\n"); return $cacheFile; } }

function pageCacheEnd($cacheFile='', $debug=FALSE) { $html = ob_get_contents(); ob_end_flush();

if (empty($cacheFile)) { } else { if ($debug) { print("<hr>writing new cacheFile: $cacheFile\n"); }

if ($fp = @fopen ($cacheFile, 'w')) { @fwrite ($fp, $html); @fclose ($fp); } } }

Ordered an Orinoco RG-1000 Wireless Access Point Kit from the other day. After unnecessary confusion with Airborne I got my hands on it yesterday. As mentioned in a recent Mobile Computing article, the RG-1000 can be used as an Ethernet bridge. I had previously only thought that the much higer priced Access Points could act in that capacity.

Setup with Windows 95 was relatively easy, though as Mobile Computing points out, Lucent doesn't make the configuration for a bridge setup known - in fact, they don't really even mention it. You are left to your own devices to figure out how to setup DHCP, NAT and such to achieve the bridge config.

I got it working on Windows, then rebooted the laptop to RH 7. After figuring out the mutliple drivers that can run these cards, and a little trial and error with modules.conf, config.opts, and wireless.opts I got it all up and running.

Speed it great - as fast as a wired connection in my environment. Range seems to be good, at least I can go up and downstairs and in all corners of my small 2 bedroom apartment.

Much thanks to Jean Tourrilhes for his vast Wireless LAN resources for Linux site.

Hopefully I can help get the Alternative PHP Cache (APC) up and running and stable. I don't really have the cash to pay Zend for the ZendCache - and surely not enough for the recurring/annual maintenance fees. Hopefully APC can do the trick!

Right now APC is crapping out on the crazy levels of class hierarchy scattered among 70+ include files that I use for my PHP Ecommerce application, VendoToSell.

Spent the day researching the best means for archiving a portion of my jazz cd collection to mp3. Ended up going with cdparanoia, lame, grip, DigitalDJ, mpg123. Slick. So far got the Miles Davis and John Coltrane Columba Recordings done. Next up my Mosaic albums.

Who needs Real Pukebox Plus? Not moi. Lame VBR 256 kbps encoding for free.

1 older entry...


prenagha certified others as follows:

  • prenagha certified prenagha as Journeyer

Others have certified prenagha as follows:

  • prenagha certified prenagha as Journeyer
  • plundis certified prenagha as Apprentice
  • nixnut certified prenagha as Apprentice
  • tmokros certified prenagha as Journeyer

[ Certification disabled because you're not logged in. ]

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!

Share this page