Search in sources :

Example 1 with MessageDigestResourceVersion

use of org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion in project wicket by apache.

the class ResourceSettings method getCachingStrategy.

/**
 * gets the resource caching strategy
 *
 * @return strategy
 */
public IResourceCachingStrategy getCachingStrategy() {
    if (resourceCachingStrategy == null) {
        final IResourceVersion resourceVersion;
        if (application.usesDevelopmentConfig()) {
            // development mode:
            // use last-modified timestamp of packaged resource for resource caching
            // cache the version information for the lifetime of the current http request
            resourceVersion = new RequestCycleCachedResourceVersion(new LastModifiedResourceVersion());
        } else {
            // deployment mode:
            // use message digest over resource content for resource caching
            // cache the version information for the lifetime of the application
            resourceVersion = new CachingResourceVersion(new MessageDigestResourceVersion());
        }
        // cache resource with a version string in the filename
        resourceCachingStrategy = new FilenameWithVersionResourceCachingStrategy(resourceVersion);
    }
    return resourceCachingStrategy;
}
Also used : FilenameWithVersionResourceCachingStrategy(org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy) RequestCycleCachedResourceVersion(org.apache.wicket.request.resource.caching.version.RequestCycleCachedResourceVersion) IResourceVersion(org.apache.wicket.request.resource.caching.version.IResourceVersion) LastModifiedResourceVersion(org.apache.wicket.request.resource.caching.version.LastModifiedResourceVersion) CachingResourceVersion(org.apache.wicket.request.resource.caching.version.CachingResourceVersion) MessageDigestResourceVersion(org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion)

Example 2 with MessageDigestResourceVersion

use of org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion in project wicket by apache.

the class ResourceMapperWithDecoratedResourcesTest method newApplication.

@Override
protected WebApplication newApplication() {
    return new MockApplication() {

        @Override
        public void init() {
            super.init();
            getResourceSettings().setCachingStrategy(new FilenameWithVersionResourceCachingStrategy(new CachingResourceVersion(new MessageDigestResourceVersion())));
            mountResource("stylesheet.css", new CssResourceReference(ResourceMapperWithDecoratedResourcesTest.class, "decorated-resource.css"));
            mountPage("/", HomePage.class);
        }
    };
}
Also used : FilenameWithVersionResourceCachingStrategy(org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy) MockApplication(org.apache.wicket.mock.MockApplication) CachingResourceVersion(org.apache.wicket.request.resource.caching.version.CachingResourceVersion) MessageDigestResourceVersion(org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion) CssResourceReference(org.apache.wicket.request.resource.CssResourceReference)

Example 3 with MessageDigestResourceVersion

use of org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion in project wicket by apache.

the class CssUrlReplacerTest method newApplication.

@Override
protected WebApplication newApplication() {
    return new MockApplication() {

        @Override
        protected void init() {
            super.init();
            getResourceSettings().setCachingStrategy(new FilenameWithVersionResourceCachingStrategy("=VER=", new MessageDigestResourceVersion()) {

                @Override
                public void decorateUrl(ResourceUrl url, IStaticCacheableResource resource) {
                    url.setFileName(url.getFileName() + DECORATION_SUFFIX);
                }
            });
        }

        @Override
        public Session newSession(Request request, Response response) {
            Session newSession = super.newSession(request, response);
            newSession.setLocale(Locale.ROOT);
            return newSession;
        }
    };
}
Also used : FilenameWithVersionResourceCachingStrategy(org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy) IStaticCacheableResource(org.apache.wicket.request.resource.caching.IStaticCacheableResource) Response(org.apache.wicket.request.Response) MockApplication(org.apache.wicket.mock.MockApplication) Request(org.apache.wicket.request.Request) MessageDigestResourceVersion(org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion) ResourceUrl(org.apache.wicket.request.resource.caching.ResourceUrl) Session(org.apache.wicket.Session)

Aggregations

FilenameWithVersionResourceCachingStrategy (org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy)3 MessageDigestResourceVersion (org.apache.wicket.request.resource.caching.version.MessageDigestResourceVersion)3 MockApplication (org.apache.wicket.mock.MockApplication)2 CachingResourceVersion (org.apache.wicket.request.resource.caching.version.CachingResourceVersion)2 Session (org.apache.wicket.Session)1 Request (org.apache.wicket.request.Request)1 Response (org.apache.wicket.request.Response)1 CssResourceReference (org.apache.wicket.request.resource.CssResourceReference)1 IStaticCacheableResource (org.apache.wicket.request.resource.caching.IStaticCacheableResource)1 ResourceUrl (org.apache.wicket.request.resource.caching.ResourceUrl)1 IResourceVersion (org.apache.wicket.request.resource.caching.version.IResourceVersion)1 LastModifiedResourceVersion (org.apache.wicket.request.resource.caching.version.LastModifiedResourceVersion)1 RequestCycleCachedResourceVersion (org.apache.wicket.request.resource.caching.version.RequestCycleCachedResourceVersion)1