org.apache.wicket.request.resource.caching
Class FilenameWithVersionResourceCachingStrategy

java.lang.Object
  extended by org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy
All Implemented Interfaces:
IResourceCachingStrategy

public class FilenameWithVersionResourceCachingStrategy
extends java.lang.Object
implements IResourceCachingStrategy

resource caching strategy that adds a version for the requested resource to the filename.

versioned_filename := [basename][version-prefix][version](.extension)

the version must not contain the version-prefix so please use an unambigous value for the version-prefix. The default version-prefix is .

Since browsers and proxies use the versioned filename of the resource as a cache key a change to the version will also change the filename and cause a reliable cache miss. This enables us to set the caching duration of the resource to a maximum and get best network performance.

Since:
1.5
Author:
Peter Ertl

Constructor Summary
FilenameWithVersionResourceCachingStrategy(IResourceVersion resourceVersion)
          create filename caching strategy with given version provider and version-prefix = ''
FilenameWithVersionResourceCachingStrategy(java.lang.String versionPrefix, IResourceVersion resourceVersion)
          Constructor
 
Method Summary
 void decorateResponse(AbstractResource.ResourceResponse response, IStaticCacheableResource resource)
          set resource caching to maximum and set cache-visibility to 'public'
 void decorateUrl(ResourceUrl url, IStaticCacheableResource resource)
          add caching related information to filename + parameters
 java.lang.String getVersionPrefix()
           
 void undecorateUrl(ResourceUrl url)
          Removes caching related information from filename + parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilenameWithVersionResourceCachingStrategy

public FilenameWithVersionResourceCachingStrategy(IResourceVersion resourceVersion)
create filename caching strategy with given version provider and version-prefix = ''

Parameters:
resourceVersion - version provider
See Also:
FilenameWithVersionResourceCachingStrategy(String, org.apache.wicket.request.resource.caching.version.IResourceVersion)

FilenameWithVersionResourceCachingStrategy

public FilenameWithVersionResourceCachingStrategy(java.lang.String versionPrefix,
                                                  IResourceVersion resourceVersion)
Constructor

Parameters:
versionPrefix - string that marks the beginning the of the version in the decorated filename
resourceVersion - resource version object
See Also:
FilenameWithVersionResourceCachingStrategy(org.apache.wicket.request.resource.caching.version.IResourceVersion)
Method Detail

getVersionPrefix

public final java.lang.String getVersionPrefix()
Returns:
string appended to the filename before the version string

decorateUrl

public void decorateUrl(ResourceUrl url,
                        IStaticCacheableResource resource)
Description copied from interface: IResourceCachingStrategy
add caching related information to filename + parameters

Specified by:
decorateUrl in interface IResourceCachingStrategy
Parameters:
url - parameters to which caching information should be added and which will be used to construct the url to the resource
resource - cacheable resource

undecorateUrl

public void undecorateUrl(ResourceUrl url)
Description copied from interface: IResourceCachingStrategy
Removes caching related information from filename + parameters. In essenese this method undoes what IResourceCachingStrategy.decorateUrl(ResourceUrl, IStaticCacheableResource) did.

Specified by:
undecorateUrl in interface IResourceCachingStrategy
Parameters:
url - parameters that were used to construct the url to the resource and from which previously added caching information should be stripped

decorateResponse

public void decorateResponse(AbstractResource.ResourceResponse response,
                             IStaticCacheableResource resource)
set resource caching to maximum and set cache-visibility to 'public'

Specified by:
decorateResponse in interface IResourceCachingStrategy
Parameters:
response -


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.