Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

getResourceSettings().setAddLastModifiedTimeToResourceReferenceUrl() has been replaced by IResourceCachingStrategy

Wicket 1.5 has a new feature called "resource caching strategy"improved support for caching. It gives you fine-grained control over caching behavior on your package resources.

There are several implementation out-of-the-box implementations of the interface

org.apache.wicket.request.resource.caching.IResourceCachingStrategy

which provide different ways of adding caching related information your package resources (e.g. CSS, javascript, images). Also it's quite pretty easy to implement roll out your own strategy.

Basically the caching strategy will decorate the package resource with a version-dependendant invariant.

The default caching strategy in development and production mode is

org.apache.wicket.request.resource.caching.FilenameWithTimestampResourceCachingStrategyFilenameWithVersionResourceCachingStrategy

See the javadoc of the class for details.

(taken from javadoc)

{{

  • resource caching strategy that adds a version for the
  • requested resource to the filename.
  • versioned_filename := basenameversion-prefixversion(.extension)
  • }}

In development mode the version string is be last modified timestamp of the resource in UNIX milliseconds. If the resource resides in a jar the timestamp of the jar file will be taken instead.

In production mode the MD5 hash of the file content will be calculated and taken as version. The calculation will be done once and be cached for the lifetime of the application.

Example:

filename = styles.css
last-modified = 1303741587000
md5-checksum=F1336A3F160F1399ECF87B6196AB1C2A
decorated-filename-in-development-mode = styles-ver-1303741587000.css
decorated-filename-in-deploymend-mode = styles-ver-F1336A3F160F1399ECF87B6196AB1C2A.css

So whenever the file changes the changed filename will cause a cache miss and the updated file will be requested from the server.

It will decorate the resource filename with a version. The version will be the timestamp of the file in development mode and the md5 hash in deployment mod.
merges the last modified timestamp of the resource into the base resource name. For a good description of this style of caching see chapter

...