Friday, September 01, 2006

Nifty Mozilla Plug-In, and New Debugging War Story

First, the new plugin. I was playing around with Last-Modified caching in web applications tonight. And for the life of me, I couldn't get it to work for one I was playing with.

Last-Modified caching is a really simple concept - you tell the browser when a document was last changed. Then, when it asks for a document again, it can say: "Hey, if the document hasn't changed since you told me it was last changed, then don't bother sending it to me again." This saves on both bandwidth and computation.

So, I knew I wanted to do this.

But, when I got all the code in place, it didn't work. Argh. But that's life as a programming. So, what I needed was a way to debug what was going on. Because this whole caching thing is done via HTTP headers, I needed a way to review them. I figured there must be a nifty plugin in Firefox to let me see what was going on behind the scenes. And Sure enough, there is.

Check out Live HTTP Headers - it will let you watch the exact request/response headers being sent between the browser and the server. Like a variety of other firefox extensions, once you start to use it, you will quickly wonder how on earth you ever developed without it.

Now onto the new Debugging War Story...

So here I am, trying to get this whole caching thing to happen. But for the life of me, no what I change, I can't get Firefox to do anything but to deliver up a fresh copy of the page.

I'm thinking to myself, how could Firefox be this broken? I'm Googling around for phrases like "Firefox Last-Modified" and "Firefox not sending If-Modified-Since," and still I can't see anyone else who is having this problem. I even browsed through the bug reports on, because I was running out of options.

One of the neat things about having the web as a resource, and having an obscure problem is that usually one of two things happen: (a) you search for the issue and the solution jumps right out at you. Or (b) you search and can't find anything. At first you might think (b) was a bad thing, but in fact, it can be good news. It can mean that chances are you just doing something so dumb that you've managed to invent a problem where there isn't one.

And that's what I did tonight.

Every time I reloaded the page to see if caching worked, I was holding down the shift key. I was doing this totally without thinking. As every good Firefox user knows, holding down the shift key during the reload process intentionally turns off caching. That's its whole point. And I'm so used to reloading pages like that, it never occurred to me that I was defeating the one thing I was testing.

So once I stopped holding down the shift key, I realized that my caching was working just fine.

Ahhh, the joys of programming. Gosh I love my job.

No comments:

Post a Comment