Minimal resourcesMost JavaScript and CSS files used by the XForms engine are available in two versions:
Both versions work exactly the same. For development and debugging of the XForms engine itself, the full version is easier to work with. But if you never work directly with these JavaScript and CSS files, as well as for deployment, the minimal versions are recommended as they will load faster in the user's web browser. You enable minimal resources in
Default [SINCE 2012-05-03]:
NOTE: Before 2012-05-03, the default was true. Combined resourcesRationaleServing external CSS and JavaScript resources can have a high performance cost on page loads. This is particularly important with the intensive use of JavaScript in Orbeon Forms. In particular, it can be shown that serving many small files is slower than serving a single large file. NOTE: In theory, HTTP pipelining can improve very much on this, but this is (very unfortunately) useless in practice at the time of writing because Internet Explorer doesn't implement it at all and Firefox / Mozilla do implement it but do not enable it by default. This is why Orbeon Forms supports the option of combining the multiple JavaScript and CSS files required for a given XForms page into one or two JavaScript files and one or two CSS file. How it worksThere are 3 categories of resources:
Resources are split into 2 groups:
The idea is that this way, in an application with multiple pages:
If all the resources belong to the baseline, only one JavaScript and one CSS files are produced. Otherwise, two JavaScript and two CSS files are produced. The URLs produced identify the resources needed by the page, for example:
When the Orbeon Forms XForms server receives a request for a combined resource, it determine what files need to be combined and outputs them all together. Furthmore, for CSS files, all URLs referred to with Some CSS and JavaScript files are never included into aggregated resources:
ConfigurationYou enable this feature in
When this is enabled, Orbeon Forms combines JS and CSS resources. Default [SINCE 2012-05-03]:
NOTE: Before 2012-05-03, the default was true. Mappings between resources URLs and the resources are stored in the The baseline of resources is configured as follows:
The value consists of a list of qualified names referring to XBL components. Resources for the components specified are always included in every page, whether the component is used by the page or not. In addition, you can enable caching on disk of combined resources with:
This cache works differently from other Orbeon Forms caches, as the result is stored in the resources, typically under:
One benefit of this mechanism is that it allows making such combined files to be served by an Apache front-end. JavaScript at the bottom of the pageThis feature is enabled by default.
[SINCE: 2011-02-21: this used to be built into theme stylesheets. It is now enabled with a property.]
The following property, if enabled, places external and inline JavaScript at the bottom of the page:
See Yahoo's Best Practices for Speeding Up Your Web Site.
Versioned resourcesAvailabilityRationaleTo further improve caching efficiency, Orbeon Forms supports enabling versioned resources. Usually, a resource such as a CSS, JavaScript or image file, is served through URLs like this one: http://localhost:8080/orbeon/xforms-server/orbeon-a8adf9b6d7d9e9ed23060a279fabed50bd829236.js
When configuring caching on the server, for example by using an Apache front-end, you may face a dilemma:
Orbeon Forms solves this by providing the option of using versioned resources, that is inserting automatically a version number within resource URLs. ConfigurationYou enable versioned resources in <property as="xs:boolean" name="oxf.resources.versioned" value="true"/>
With this, the resource above is served as follows: http://localhost:8080/orbeon/xforms-server/3.6.0.200803010236/orbeon-a8adf9b6d7d9e9ed23060a279fabed50bd829236.js
The XForms Server component, which serves the resource in this case, sets an expiration date far in the future. For example, this is the description of the cache entry in the Firefox Key: http://localhost:8080/orbeon/xforms-server/3.6.0.200803010236/orbeon-6535536d5b557b4339c5ebc5b4fc091242fe5546.css This means that the resource can effectively be cached "for ever" by a client. In case the client visits Orbeon Forms pages often, the resources will be availabe from cache, therefore reducing page loading times and server load as well. When Orbeon Forms is upgraded on the server, the version number changes as well. An XForms page will refer to resources with the new version number, so the cached resource is not used by the browser and a new resource is loaded from the server, before being cached. This "magic" is enabled simply with the inclusion of the Orbeon Forms version number in the URL. Only CSS and JavaScript resources used by the XForms engine are loaded through the XForms Server component. Other resources like images referred by XForms stylesheets are served by the Page Flow Controller, through URLs like this one: http://localhost:8080/orbeon/ops/images/xforms/error.gif
With resource versioning enabled, the URL becomes: http://localhost:8080/orbeon/3.6.0.200803010236/ops/images/xforms/error.gif
When resource versioning is enabled, the Page Flow Controller by default serves all the resources defined in <config xmlns="http://www.orbeon.com/oxf/controller" xmlns:oxf="http://www.orbeon.com/oxf/processors"><!-- GIF images are loaded following oxf.resources.versioned --><files path-info="*.gif"/><!-- More file definitions here -->...<!-- PDF files are not versioned --><files path-info="*.pdf" versioned="false"/><!-- More file definitions here -->...<!-- More page definitions here -->...</config>
Conversely, resource URLs produced by an XForms page are automatically rewritten following the Page Flow's The versioning mechanism is made available to your own application resources as well. Any resource whose path doesn't start with <property as="xs:string" name="oxf.resources.version-number" value="1.6.3"/>
Note that if this property is commented out or missing, no versioning takes place for your application resources even if For deployed application, you should upgrade the application version number whenever you modify application resources so that clients retrieve the proper resources. The following scenario shows the entire lifecycle for application resources:
From client-side JavaScript, you can access the application version number as follow: var version = ORBEON.util.Utils.getProperty(APPLICATION_RESOURCES_VERSION_PROPERTY);
Since 2011-10-05, versioned resources served by the PFC (that is all the resources except the XForms engine's CSS and JavaScript resources) also get an aggressive expiration date. Before 2011-10-05, versioned resources served by the PFC would get the usual HTTP "age of the resource plus 10%" expiration heuristic instead of an aggressive expiration date. If you want to fully leverage client-side caching capabilities, you may want to use an Apache front-end or a Servlet filter to modify the Expires header of those resources. With Apache, you can use mod_expires. In case you use Apache, you can in addition configure a rewriting rule with mod_rewrite to allow Apache to directly load resources containing a version number, as shown below. Note
We recommend restarting Orbeon Forms after changing the Examples of Apache configurationsHere is how you can configure Apache to serve Orbeon Forms resources. This assumes the following:
Without resources versioning: RewriteEngine on With resources versioning: RewriteEngine on Note
The rewriting rules above have special handling of PNG images for IE 6: when that browser is detected, any request for PNG image having a corresponding GIF image serves the GIF images instead. If you don't need that behavior, remove the corresponding lines in the rules above. All in all, the rules above perform the following:
|