Tuesday, January 15, 2008

Wicket is taunting me.

After some vigorous hand wringing and what I thought was thorough forum searching, it turns out that no custom behavior/code is necessary to handle adding a browser-cache-stopping-but-not-totally-random-or-once-in-a-while-new-when-it-shouldn't-be url parameter onto JS and CSS links in Wicket.

The magic line of wicket code which eludes forums and wiki documentation follows...drum roll...

In your Application's init() method add the following. :

getResourceSettings().setAddLastModifiedTimeToResourceReferenceUrl(true);

Hmph... method names don't get much clearer than that do they?

This causes a 'wicket:lm=######' (lm stands for lastModified) url parm to be appended to package resource url's that are rendered. Now the browser has a url based clue as to when it REALLY needs to refresh from the server.

It's nice that it can be turned on in one place for all generated package resource url's.

No comments: