We just moved from GWT to Wicket 1.4. While very happy in general, we still have a bit of a learning curve for certain things that GWT made simple. One of those things is resource caching.
How can I configure our app’s resources (CSS in particular) so that they aren’t downloaded with each page request?
We’re seeing some flickering on certain page elements because the styles aren’t being applied immediately, presumably because the style sheets are being downloaded each time. I traced through our logs and indeed, I’m seeing requests for the stylesheets on nearly every page request.
We’re referencing the CSS directly in our HTML files like so:
<link href="/css/ag.screen.css" rel="stylesheet" type="text/css">
<link href="/css/ag.base.css" rel="stylesheet" type="text/css">
I’m not sure it matters, but all our pages are mounted with IndexedParamUrlCodingStrategy, as we need them to be both bookmarkable and have particular URL structures.
I tried implementing what Stefan Fußenegger suggests in his blog (i.e. referencing the CSS via a header contribution rather than in the HTML directly), but that didn’t seem to help (I tried checking the headers with “curl -I”).
Is there a standard way of setting Cache-Control or Expiration headers for resources in Wicket 1.4? Is it worth moving to Wicket 1.5 for this? (I’m hesitant to do so because it’s not officially released yet).
Edit: I just gave 1.5 another try, but the lack of documentation is really a roadblock at this point. IndexedParamUrlCodingStrategy and related classes are are gone, and the migration guide has almost nothing to say about it.
Edit 2: I just noticed something very odd- when I arrive at one of my pages either by directly entering the URL, or by clicking a BookmarkablePageLink, the resources referenced on that page (CSS, images, etc) seem to get cached (I see no requests for them in my logs). But if I arrive at the same page via a form submission, all of the resources are downloaded again. Why does a form submission cause resources referenced on the page to be re-downloaded?
Since you are moving to Wicket I’d recommend you to use 1.5RC4.2. Looking at the bug reports about this RC I think the next one may be 1.5.0Final.
About caching see this wiki page: https://cwiki.apache.org/WICKET/caching-in-wicket-15.html.
It is about 1.5 but it also says what are the differences against 1.4.