|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.request.resource.caching.AbstractResourceCachingStrategy org.apache.wicket.request.resource.caching.FilenameWithTimestampResourceCachingStrategy
public class FilenameWithTimestampResourceCachingStrategy
resource caching strategy that adds a last-modified timestamp to the filename
timestamped_filename := [basename][timestamp-prefix][last-modified-milliseconds](.extension) Normally the resource names won't change when the resource ifself changes, for example when you add a new style to your CSS sheet. This can be very annoying as browsers (and proxies) usally cache resources in their cache based on the filename and therefore won't update. Unless you change the file name of the resource, force a reload or clear the browser's cache the page will still render with your old CSS. Depending on HTTP response headers like 'Last-Modified' and 'Cache' automatic cache invalidation can take very, very long or neven happen at all. Enabling timestamps on resources with this strategy will inject the last modification time of the resource into the filename (the name will look something like 'style-ts1282915831000.css' where the large number is the last modified date in milliseconds and '-ts' is a prefix to avoid conflicts with filenames that already contain a number before their extension. * Since browsers and proxies use the filename of the resource as a cache key the changed filename will not hit the cache and the page gets rendered with the changed file.
Field Summary | |
---|---|
protected static String |
DEFAULT_TIMESTAMP_SUFFIX
|
Fields inherited from class org.apache.wicket.request.resource.caching.AbstractResourceCachingStrategy |
---|
TIMESTAMP_KEY |
Constructor Summary | |
---|---|
FilenameWithTimestampResourceCachingStrategy()
Constructor |
|
FilenameWithTimestampResourceCachingStrategy(String timestampSuffix)
Constructor |
Method Summary | |
---|---|
void |
decorateResponse(AbstractResource.ResourceResponse response)
set resource caching to maximum and set cache-visibility to 'public' |
void |
decorateUrl(ResourceUrl url,
ResourceReference reference)
add caching related information to filename + parameters |
String |
getTimestampPrefix()
|
void |
undecorateUrl(ResourceUrl url)
Removes caching related information from filename + parameters. |
Methods inherited from class org.apache.wicket.request.resource.caching.AbstractResourceCachingStrategy |
---|
getLastModified, isLastModifiedCacheEnabled, setLastModifiedCacheEnabled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final String DEFAULT_TIMESTAMP_SUFFIX
Constructor Detail |
---|
public FilenameWithTimestampResourceCachingStrategy()
public FilenameWithTimestampResourceCachingStrategy(String timestampSuffix)
timestampSuffix
- string appended to the filename before the timestampMethod Detail |
---|
public final String getTimestampPrefix()
public void decorateUrl(ResourceUrl url, ResourceReference reference)
IResourceCachingStrategy
url
- parameters to which caching information should be added and which will be used to
construct the url to the resourcereference
- resource referencepublic void undecorateUrl(ResourceUrl url)
IResourceCachingStrategy
IResourceCachingStrategy.decorateUrl(ResourceUrl, ResourceReference)
did.
url
- parameters that were used to construct the url to the resource and from which
previously added caching information should be strippedpublic void decorateResponse(AbstractResource.ResourceResponse response)
response
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |