Module org.apache.wicket.core
Class FilenameWithVersionResourceCachingStrategy
java.lang.Object
org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy
- All Implemented Interfaces:
IResourceCachingStrategy
public class FilenameWithVersionResourceCachingStrategy
extends 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 unambiguous value for the version-prefix
. The default
version-prefix
is "-ver-"
.
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
-
Field Summary
Fields inherited from interface org.apache.wicket.request.resource.caching.IResourceCachingStrategy
URL_VERSION
-
Constructor Summary
ConstructorDescriptionFilenameWithVersionResourceCachingStrategy
(String versionPrefix, IResourceVersion resourceVersion) ConstructorFilenameWithVersionResourceCachingStrategy
(IResourceVersion resourceVersion) create filename caching strategy with given version provider andversion-prefix = '"-ver-"'
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears any stateful informationvoid
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 + parametersfinal String
void
undecorateUrl
(ResourceUrl url) Removes caching related information from filename + parameters.
-
Constructor Details
-
FilenameWithVersionResourceCachingStrategy
create filename caching strategy with given version provider andversion-prefix = '"-ver-"'
- Parameters:
resourceVersion
- version provider- See Also:
-
FilenameWithVersionResourceCachingStrategy
public FilenameWithVersionResourceCachingStrategy(String versionPrefix, IResourceVersion resourceVersion) Constructor- Parameters:
versionPrefix
- string that marks the beginning the of the version in the decorated filenameresourceVersion
- resource version object- See Also:
-
-
Method Details
-
getVersionPrefix
- Returns:
- string appended to the filename before the version string
-
decorateUrl
Description copied from interface:IResourceCachingStrategy
add caching related information to filename + parameters- Specified by:
decorateUrl
in interfaceIResourceCachingStrategy
- Parameters:
url
- parameters to which caching information should be added and which will be used to construct the url to the resourceresource
- cacheable resource
-
undecorateUrl
Description copied from interface:IResourceCachingStrategy
Removes caching related information from filename + parameters. In essenese this method undoes whatIResourceCachingStrategy.decorateUrl(ResourceUrl, IStaticCacheableResource)
did.- Specified by:
undecorateUrl
in interfaceIResourceCachingStrategy
- 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 interfaceIResourceCachingStrategy
- Parameters:
response
-
-
clearCache
Description copied from interface:IResourceCachingStrategy
Clears any stateful information- Specified by:
clearCache
in interfaceIResourceCachingStrategy
-