Hey Daniel, you may wish to stay away from Filters if you are going to contribute this to Trinidad. It'll break portlet compatibility.

That said, what is the problem you are trying to solve here? Is it that resources are not currently being cached in your environment by the browser, or that the Trinidad ResourceServlet seems to be too slow.

I do know that I was having some issues with the cachability of static resources on the Oracle Application Server because the jsessionId was changing the url on me. I was able to create a configuratior which disabled the encoding of resource urls when running in a servlet environment and the cachability returned. I didn't submit it to Trinidad because I feared it would break environments where the session wasn't tracked as a cookie.

Scott

Daniel Niklas wrote:
Hi,

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 js-libraries, 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, when using trinidad standard skin.

TrinidadResourceServlet, Line 458:

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

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

// Set Expires to current time + one year. long currentTime = System.currentTimeMillis();

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

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

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

To enable caching, you have to provide a version number in your
weblets.config. When you provide a version, the generated urls are containing version information, too. The version number could be the same as the version number of 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);

(see https://weblets.dev.java.net/trunk/shortdoc/introduction.html)

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
Daniel

Reply via email to