myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Niklas <>
Subject Re: Need Filter that caches resources - a more general Extensions Filter?
Date Tue, 05 Feb 2008 15:02:04 GMT


Working on the caching feature, i found out the following:

The TrinidadResourceServlet has already build in Cache-Control. It sets the 
expires header to "+ 1 year". This is good in case of requesting
because theses generated files has the trinidad version as suffix in its 
filename. (e.g. "adf/jsLibs/Common1_0_5.js")

There isn't a suffix for image requests. This will be a problem, when images 
changes in a future version. (e.g. "/adf/images/t.gif"). 

The file "t.gif" seems to be a special case, because this is part of the 
XhtmlRenderer and is used for generating gabs!? Other images, e.g. 
"adf/images/dfb.gif", are part of the skin. There will be the same problem,
using trinidad standard skin.

TrinidadResourceServlet, Line 458:

      // We set two headers: Cache-Control and Expires. // This combination
      browsers know that it is // okay to cache the resource indefinitely.

      // Set Cache-Control to "Public". response.setHeader("Cache-Control", 

      // Set Expires to current time + one year. long currentTime = 

      response.setDateHeader("Expires", currentTime + ONE_YEAR_MILLIS);

I'm using weblets, to load resources. You can enable caching for weblets,
The documentatin says:

"Weblets use versioning to leverage the browser cache behavior so that
resources can be downloaded and cached as efficiently as possible. The
only needs to check for new updates when the cache has been emptied or when
component library has been upgraded at the web server."

To enable caching, you have to provide a version number in your
When you provide a version, the generated urls are containing version 
information, too. The version number could be the same as the version number
the corresponding jar.

WebletResponseImpl, Line 82 (weblets 0.4)

    long now = System.currentTimeMillis(); long never = now + 1000 * 60 * 60
    24 * 365; _httpResponse.setDateHeader("Expires", never);


I don't have other static resources. For this reason i don't need another 
filter, that adds cache control headers or something similar.

Best regards
View this message in context:
Sent from the MyFaces - Users mailing list archive at

View raw message