Click here to register.
      

WebGUI Page Cache Quirks

Design Squid
WebGUI Page Cache Quirks
fdillon · 10/22/2008 9:54 pm

While developing the new Help Desk that was launched at the beginning of October, I ran into a few new bumps that I'll be blogging about over the next few weeks.

The first one has to do with how WebGUI assets, specifically wobjects, deal wtih browser cache.  It all started when I was trying to get YUI's tab control to work properly in my base asset.  I finally figured out how to get the tabs configured so they would dynamically change the content when you clicked them, but for reasons that were baffeling me, the pages I asked the second and third tabs to request when clicked wouldn't load.

It was at my darkest moment (I was getting ready to do unspeakable things to my laptop) when Graham looked over my shoulder and mentioned a 4 line method in the Asset class that I should consider overriding called getContentLastModified.

After doing a bit of digging I found out that these 4 lines of code were the cause of my frustration (and near anyeurysm).  WebGUI's Wobject class has a line of code in it's www_view method that looks like this:

    $self->session->http->setLastModified($self->getContentLastModified);

What this does is set the date that the page was Last Modified field in the header so the browser knows that something new has happened and it should poll the server again.  If you do not override this method, once a user has your page in browser cache the content will not poll the server again until the asset is updated and the revision date has changed!

The moral of this story is to make sure, when developing your own wobjects, you override this method and properly return the time the content of your page was last modified so the browser polls the server properly. In the case of the Help Desk (which constantly updates without the revision date of the wobject changing), I needed it to be ultra lazy:

#-------------------------------------------------------------------
sub getContentLastModified {
    return time;
}

·
Stick
Lock
Subscribe