Firebug's 'cached' label is misleading

It's beyond me how anyone could develop without Firebug; it's like assembling something from Ikea without an allen wrench. On occasion I find myself relying on Firebug a bit to much though, and today was one of those days.

I was troubleshooting a JavaScript heavy Intranet application and the first thing I did was double-check that Apache was using mod_deflate to compress content sent to the browse - it wasn't. I enabled that, albeit sloppily, since I can guarantee the versions of IE in use.

LoadModule deflate_module modules/mod_deflate.so
 
AddOutputFiterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript

I browsed to the site in question with Firefox and IE and it was significantly faster on a fresh, uncached load, but for some reason Firebug was only reporting that content was coming from cache on a reload of a page, not on visits to previously visited pages. I'd never dug too deep into the caching settings of Apache, but I did notice that no ETag headers were being sent. Not a problem, it's only one line in my Apache conf file.

FileETag All

No change though. I opened up LiveHTTPHeaders and to my surprise I only saw a single request for the page itself. Reloading without caching enabled showed me all of the requests for my JavaScript, CSS and images. My Apache access_log confirmed both tests, so it was definitely something to do with Firebug. I searched the Firebug Group and found a few posts that provided some insight:

I didn't feel like learning about how to write Firefox extensions, or digging into the Firebug source, but it looks like Firebug updates the Net tab based on a hook to http-on-modify-request whereas LiveHTTPHeaders and TamperData use http-on-examine-response. From the Mozilla Developer Center:

  • http-on-modify-request - Called as a http request is made. The channel is available to allow you to modify headers and such.
  • http-on-examine-response - Called after a response has been received from the webserver. Headers are available on the channel.

According to Adam in this thread, you don't have access to the caching information until onExamineResponse, so it sounds like Firebug updates the Net tab when onModifyRequest is triggered.

In short, you can't trust Firebug's Net tab to accurately tell you if an item was loaded from cache. It sounds like this is a problem with what Firefox sends to an nsiObserver object, but I'd love to have someone confirm that.

 

Leave a Reply