List of usage examples for org.apache.wicket.request.resource.caching FilenameWithVersionResourceCachingStrategy FilenameWithVersionResourceCachingStrategy
public FilenameWithVersionResourceCachingStrategy(String versionPrefix, IResourceVersion resourceVersion)
From source file:name.martingeisse.wicket.application.AbstractMyWicketApplication.java
License:Open Source License
@Override protected void init() { super.init(); /* Configure wicket. * // w w w . j a v a 2s . c o m * We disable the javascript compressor here since (a) it fails for the "minified" JQuery -- * producing invalid output code -- and (b) strips licenses, which would certainly get us * into legal trouble. * * We also disable GZIP compression here, and instead rely on a centralized GZIP filter. * This is because only JavascriptPackageResource uses Wicket's built-in compression; * CSS resources for example do not. Wicket also doesn't set the Vary: HTTP header. * Centralized GZIP handling (and caching) should be more manageable. */ getApplicationSettings().setDefaultMaximumUploadSize(Bytes.megabytes(16)); getResourceSettings().setJavaScriptCompressor(null); getMarkupSettings().setStripWicketTags(true); getMarkupSettings().setStripComments(true); getMarkupSettings().setDefaultMarkupEncoding("utf-8"); getMarkupSettings().setCompressWhitespace(true); // mount package resources using their revision number // NOTE: FirstLineResourceVersion is nice but only works when the file is *committed* on changes. // LastModifiedResourceVersion should do as long as the last-modified-date is preserved on deployment. getResourceSettings().setCachingStrategy(new FilenameWithVersionResourceCachingStrategy("-nocache-", new CachingResourceVersion(new LastModifiedResourceVersion()))); }
From source file:org.devgateway.toolkit.forms.wicket.FormsWebApplication.java
License:Open Source License
/** * optimize wicket for a better web performance This will be invoked if the * application is started with -Dwicket.configuration=deployment *//*from w w w .j a v a 2 s. c o m*/ private void optimizeForWebPerformance() { // add javascript files at the bottom of the page setHeaderResponseDecorator(new RenderJavaScriptToFooterHeaderResponseDecorator("scripts-bucket")); // This is only enabled for deployment configuration // -Dwicket.configuration=deployment // The default is Development, so this code is not used if (usesDeploymentConfig()) { getResourceSettings().setCachingStrategy(new FilenameWithVersionResourceCachingStrategy("-v-", new CachingResourceVersion(new Adler32ResourceVersion()))); getResourceSettings().setJavaScriptCompressor( new GoogleClosureJavaScriptCompressor(CompilationLevel.SIMPLE_OPTIMIZATIONS)); getResourceSettings().setCssCompressor(new YuiCssCompressor()); getFrameworkSettings().setSerializer(new DeflatedJavaSerializer(getApplicationKey())); getMarkupSettings().setStripComments(true); } else { getResourceSettings().setCachingStrategy(new NoOpResourceCachingStrategy()); } getRequestCycleSettings().setRenderStrategy(RenderStrategy.ONE_PASS_RENDER); }