Getting started with the Optimizer service

This page is the starting point for learning about the Optimizer service. The following topics are covered:

Overview:

The Optimizer service is a JAX-RS based service that delivers Dojo Toolkit for JavaScript resources to clients in an optimized form, including content for specific user-agents, compression, and customizable HTTP caching and expiration.

The Optimizer service sets HTTP caching and expiration data based on a ratio of the age of the on-disk resources, and saves compressed representations of resources to serve subsequent compression-aware clients.

The Optimizer service also automatically selects pre-built distributions of Dojo tailored to specific user-agents when available.

Prerequisites:

Product prerequisite Version
Java Technology Edition 5.0 and later
Java Platform, Enterprise Edition 5 (Java EE) application server and later

WebSphere Application Server Version 6.1.0.x and later

WebSphere Application Server Community Edition Version 2.X.

Web browser Any modern web browser, such as: Internet Explorer 7 and later Mozilla Firefox 3.x and later Google Chrome Safari Opera

Using the Optimizer service

The Optimizer service has the Dojo Toolkit for JavaScript from the Feature Pack for Web 2.0 and Mobile already packaged within the .war file packaged in the appsvcs-optimizer.ear file. The application is immediately installable and deployable. However, if you want to maintain your own Dojo Toolkit for JavaScript elsewhere on the file system of the server on which this application is installed, you can perform the following steps, which are optional:

  1. Extract the .war file from the appsvcs-optimizer.ear file.
  2. Extract the WEB-INF/web.xml file from the .war file.
  3. Edit the WEB-INF/web.xml file. Set the param-value for the param-name com.ibm.ws.mobile.appsvcs.optimizer.srcPath to the full path of the file system directory in which you have the folder named "dojo", which contains the Dojo you intend to make available via the Optimizer service.
  4. Package the WEB-INF/web.xml file back into the .war file.
  5. Package the .war file back into the appsvcs-optimizer.ear file.

Dojo Toolkit for JavaScript has a builder that can produce optimized builds. These too can be hosted under the "dojo" directory to which you have configured the Optimizer service to use. For example, you might want to host an older version of Dojo. Therefore, you might also create the directory, "dojo/1.5/".

There is a single special case that Optimizer service currently supports. The Dojo builder supports a webkitMobile flag that produces a Dojo build that is optimized for WebKit-based Web browsers. The Optimizer service will use the User-Agent header of any incoming request to detect if it is a WebKit client, and look for the requested file in a directory named dojo_webkit that is a peer to the dojo directory. Existence of the dojo_webkit directory is entirely optional, but if it exists and contains a Dojo build that used the webkitMobile=true flag, you might achieve slightly better performance on WebKit based clients.

To use the Optimizer service, perform the following steps:

  1. Install the Optimizer service enterprise archive (.ear) file.
  2. Update the references to Dojo resources (CSS and JavaScript) in your web application to point to the Dojo files beneath the Optimizer service context root followed by "rest/optimizer/" (for example, /appsvcs-optimizer/rest/optimizer/dojo/dojo.js).

Configuring the Optimizer service

The Optimizer service reads a number of optional ServletConfig parameters that can be configured using the META-INF/web.xml file.

Parameter Description
com.ibm.ws.mobile.appsvcs.optimizer.srcPath

Identifies the absolute file system path of the dojo build.

Default: dojo/ (located under the WAR file)

com.ibm.ws.mobile.appsvcs.optimizer.cacheDeltaFactor

The Optimizer service sets the HTTP cache expiration time of resources based on a fraction of how old the on-disk representation is. This directive specifies the floating point number that the age will be divided by to determine how long clients will be permitted to cache a file.

Values: Floating point literal to divide the age

Default: 1000f, .01% of the age of the file

com.ibm.ws.mobile.appsvcs.optimizer.cacheDeltaMin

When Expires or Cache-Control headers are issued by the service, this setting dictates the minimum number of seconds in the future that the resources remain cacheable. Recently updated files will be cached by clients for at least the amount of time specified in this directive.

Attention: When a HTTP client caches a resource, there is no way to invalidate that at a subsequent date; therefore take care in increasing this number.

Values: Number of seconds

Default: 5

com.ibm.ws.mobile.appsvcs.optimizer.cacheDeltaMax

When Expires or Cache-Control headers are issued by the service, this setting dictates the maximum number of seconds in the future that the resources remain cacheable. Files that have not been updated for long periods of time will be cacheable by clients for no longer than the number of seconds specified in this directive.

Values: Number of seconds

Default: 900

com.ibm.ws.mobile.appsvcs.optimizer.sendExpires

Controls whether the Optimizer service sends the HTTP Expires header used by private and shared caches.

Values: true or false

Default: true

com.ibm.ws.mobile.appsvcs.optimizer.sendETAG

Controls whether the Optimizer service sends the HTTP ETag header used by private and shared caches.

Values: true or false

Default: true

com.ibm.ws.mobile.appsvcs.optimizer.sendCCMaxAge

Controls whether the Optimizer service sends the HTTP Cache-Control header with the max-age parameter, used by private caches.

Values: true or false

Default: true

com.ibm.ws.mobile.appsvcs.optimizer.noVary

Controls whether the Optimizer service sends the HTTP Vary header to indicate that the response took into account headers such as User-Agent and Accept-Encoding.

Values: true or false

Default: false

Installing the Optimizer service

Refer to the following version-specific installation instructions:

WebSphere Application Server installation instructions

This section describes the procedure for installing the Optimizer service on Version 6.1.0.X and later of the IBM WebSphere Application Server. It is assumed that you are familiar with application installation and administration for the application server.

Before you begin:

Locate the Optimizer service enterprise archive (EAR) file that is provided with your product installation. You can find the EAR file in your installation tree where you installed the IBM WebSphere Application Server Feature Pack for Web 2.0 and Mobile. For example, if you installed the feature pack in the following location:

Platform Location
Linux and UNIX: /opt/WebSphere/AppServer
z/OS mount point: <install_root>
Windows: c:\WebSphere\AppServer

Then you can find the EAR file at:

Platform Location
Linux and UNIX: /opt/WebSphere/AppServer/web2mobilefep_1.1/installableApps/application_services/optimizer/appsvcs-optimizer.ear
z/OS: <install_root>/web2mobilefep_1.1/installableApps/application_services/optimizer/appsvcs-optimizer.ear
Windows: c:\WebSphere\AppServer\web2mobilefep_1.1\installableApps\application_services\optimizer\appsvcs-optimizer.ear

Installing the Optimizer service using the administrative console

  1. Log into the administrative console for the application server.
  2. Navigate to Applications > New Application. (Note: In WebSphere Application Server Version 6.1, select Install New Application)
  3. Select New Enterprise Application. (Note: In WebSphere Application Server Version 6.1, skip this step)
  4. Browse your file system, and select the appsvcs-optimizer.ear file that you located earlier. Click Next.
  5. Click Next to prepare for the application installation. (Note: In WebSphere Application Server Version 6.1, skip this step)
  6. Click Next to accept the default installation options.
  7. Click Next to accept the default options for map modules to servers.
  8. Click Next to accept the default options for Metadata for modules. (Note: In WebSphere Application Server Versions 6.1 and 7, skip this step)
  9. Click Next to accept the default options for map virtual hosts for web modules.
  10. Review the summary of the installation options.
  11. Click Finish.
  12. Click Save to the master configuration.
  13. Navigate to Applications > Application Types > WebSphere Enterprise Applications. (Note: In WebSphere Application Server Version 6.1, Navigate to Applications > Enterprise Applications)
  14. Select the IBM WebSphere Application Server - Optimizer service, and click Start.

Access the installed application demo client

Point your web browser to your application server installation: http://<application server hostname>:<port>/appsvcs-optimizer/

The application server host name and port number are specific to your application server installation. An application server default installation web container port is 9080. If you are running your web browser on the same workstation as your application server installation and have taken all the default values, then use the following URL: http://localhost:9080/appsvcs-optimizer/.

WebSphere Application Server Community Edition Version 2.X installation instructions

This section describes the procedure for installing the Optimizer service into Version 2.X of the IBM WebSphere Application Server Community Edition. It is assumed that you are familiar with application installation and administration for the application server.

Before you begin

Locate the Optimizer service enterprise archive (EAR) file that is provided with your product installation. You can find the EAR file in your installation tree where you installed the IBM WebSphere Application Server Feature Pack for Web 2.0 and Mobile. For example, if you installed the feature pack in the following location:

Platform Location
Linux and UNIX: /opt/WebSphere/AppServerCommunityEdition
Windows: c:\WebSphere\AppServerCommunityEdition

Then, you can find the EAR and library files at:

Platform Location
Linux and UNIX: /opt/WebSphere/AppServerCommunityEdition/web2mobilefep_1.1/AppServices/installableApps/optimizer/appsvcs-optimizer.ear
Windows: c:\WebSphere\AppServerCommunityEdition\web2mobilefep_1.1\AppServices\installableApps\optimizer\appsvcs-optimizer.ear

Installing the Optimizer service through the administrative console

Log into the administrative console for the application server.

  1. Click Applications > Deployer in the left menu. (Note: In WebSphere Application Server Community Edition Version 2.0, click Applications > Deploy New)
  2. In the Archive field, browse your file system, and select the appsvcs-optimizer.ear file that you located earlier. Leave the Plan field empty and the default options selected. Then, click Install.

The application starts automatically, and installation is complete.

Access the installed application demo client

Point your web browser to your application server installation: http://<application server hostname>:<port>/appsvcs-optimizer/.

The application server host name and port is specific to your application server installation. The WebSphere Application Server Community Edition server default installation web container port is 8080. If you are running your browser on the same workstation as your application server installation and have accepted all the default values, then use the following URL:

http://localhost:8080/appsvcs-optimizer/