unload Events in Safari

May 4 2005

Generally I avoid unload event handlers because their behavior is poorly defined. However, I found myself working on a project that necessitated their use. Despite my best efforts, Safari 1.3 (312) and 2.0 (412) appear to ignore my unload event handlers. PPK has made mention of the problem. I’ve found one technique that gets the unload to fire in Safari...

Making dynamic PHP pages cacheable

Mar 24 2005

RD2 launched our new site yesterday. One of my interests was in building RESTful URI for the website. The site is very minimal and only has sections for about, work and contact. Inside of work we break it down by client and then by section number. You end up with URI like work/entrust/1. The work portfolio section is built out with a PHP file...

Getting the browser to cache your dynamically generated images

Dec 29 2004

When building a web application you sometimes need to dynamically generate the image. In my case I’m not using HTTP authentication so I have to secure the images another way. I tucked the images outside of the document root and pull them in through a php script as needed. At it’s simplest your php script merely sets the Content-Type, Content-Length and dumps the image.

  $fh=@fopen('path/to/image.jpg','rb');
  if ($fh) {
    header('Content-Type: image/jpeg');
    $s_arr = fstat($fh);
    header('Content-Length: '.$s_arr['size']);
    fpassthru($fh);
  }

This is all well and good except that php is adding all sorts of headers to prevent the browser from caching...

Building Better Web Apps

Dec 15 2004

As a web application developer I get frustrated by the sluggish user interface that most web applications provide. I want interaction with a web application to be as quick as a desktop application. A number of web applications take advantage of the XmlHttpRequest object, Google suggest being a recent notable addition. All versions of IE 5 and up have XmlHttpRequest, as well as Safari and the Mozilla based browsers. This magic little object lets you make asynchronous HTTP requests behind the scenes and dynamically update the web browser...