Resource Accelerate is a J2EE web application filter that provides three signficant performance enhancements to web applications that use CSS, JavaScript, and shared images in a simple, easy to use package. Resource Accelerate provides header caching which can significantly reduce the number of requests a browser needs to make for a web application when multiple pages share the same file resources. Resource Accelerate also provides Gzipping service that can signficantly reduce the size of files that are transferred (often 60-80% for JS or CSS files). Also Resource Accelerate can apply Dojo's ShrinkSafe JavaScript compression as well. Together these performance enhancements can provide a signficant performance improvement to web sites and applications. While these enhancements can be achieved in various other ways, Resource Accelerate provides a well optimized simple package to achieve quick performance increase. You can simply add the filters and your resources will be delivered with proper caching directives and compression without having to deal with builds.
Resource Accelerate will apply the HTTP caching header directives to all responses from a J2EE. These caching directives indicate to a browser that the browser does not need to make a request to the server for each resource for each new page load. These can provide much faster page load times when navigating between pages that share resources such as CSS, JavaScript, and image files. By default with Tomcat, there are no caching directives sent to the browser. However, there is a last modified date included in the header. Browsers will use this to make If-Modified-Since requests, so that the browser does not need to download the every entire resource file for each page encountered. However, with only the If-Modified-Since header set, the browser still must make a request to the server to check to make sure the resource has not changed. Generally with web applications, most resources such as JavaScript, CSS, and images will rarely (or never) change, and allowing the browser to cache these resources can greatly reduce the number of requests that a browser needs to make. This can be particularly important when accessing pages on high latency connections. For developers, clicking refresh on the browser will still cause the browser to request the most recent copy from the server even if it has the resource in cache.
The cache expiration time can be configured with the filter settings in your web.xml. The expiration-time parameter indicates how long resources should be kept in browser cache before expiring. This time is specified in milliseconds. The default expiration time is one day. The cache headers can be disabled by setting the cache-headers-enabled parameter to false.
Resource Accelerate can compress files using gzip. Resource Accelerate will not only gzip a file, but it will also cache the gzipped file in order to reduce the processing required to compress files on the fly for each request. By acting as a filter, the gzipper can gzip resources from servlets, jsps, and static files. The gzipper will automatically check on every request to make sure that the cached compressed file is most recent version of the original resource so there will never be a stale file delivered to the client. Many people do not like to use gzip compression on their servers because of the extra load on the servers, but by using caching there is little or even reduced load on servers with this technique. As is setup in the default configuration you should not apply compression to gifs, jpegs, or pngs as they will not efficiently compress. CSS, JavaScript, and static Html files can be compressed and often can be compressed 60-80%. The caching of the gzip compression can be disabled by setting the cached-compressed-data configuration parameter to false. This can be useful for content that is always dynamically generated.
Resource Accelerate can also perform JavaScript compression using Dojo's ShrinkSafe. This is an additional option that can be set on the compression filter. Set shrink-js to true in order to enable JavaScript compression. By combining ShrinkSafe compression with Gzip compression it is very common to achieve 85-90% compression. The advantage of using Resource Accelerate to apply ShrinkSafe is that it is not necessary to do any builds. JavaScript files are automatically recompressed when they are modified and requested. By default ShrinkSafe compression is not enabled because it is more difficult to debug applications with it on. We recommend enabling ShrinkSafe in your staging (compressed JS should be tested before going live) and production environment.
To install Resource Accelerate into your web application, simply copy the lib/resourceaccelerate.jar into your lib directory, and add the filters from the conf/web.xml into your applications web.xml file in the filters section. You may configure to the filters to use different cache settings, and apply to different file types, however the default settings are recommended and should be appropriate and provide significant performance enhancements in most situations. Ensure that your J2EE application server is fielding all requests that need to be compressed. If an Apache web server is in front of a Tomcat server, the compression will only work if Apache sends all the requests to Tomcat.
Copyright (C) 2007 Xucia Incorporation
Author - Kris Zyp - kriszyp@xucia.com
Resource Accelerate is licensed with Mozilla Public License 1.1