All Posts Made by
Matt Midboe

unload Events in Safari

Matt Midboe @ 04 May 2005 :: Front-End Development :: comments (10)

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. (more…)

Making dynamic PHP pages cacheable

Matt Midboe @ 24 Mar 2005 :: Back-End Development :: comments (6)

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. This creates the problem of a non-cacheable page. (more…)

Getting the browser to cache your dynamically generated images

Matt Midboe @ 29 Dec 2004 :: Back-End Development :: comments (1)

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. By overriding php’s headers and adding some of our own we get a much more intelligent solution that allows the browser to cache images locally if they have not changed. The first thing we need to do is generate an Entity Tag or Etag header. (more…)

Building Better Web Apps

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. Apple has a great writeup on XmlHttpRequest in Safari.

Over the coming weeks I am going to publish a series of articles on using XmlHttpRequest that demonstrate the following tasks:

  • Demonstrate how to dynamically update form elements
  • Using a POST based XmlHttpRequest for when you need to update a lot of stuff
  • A technique for making sure the form works without Javascript
  • How to use basic authentication with the request