AssetsPage edited by Howard M. Lewis ShipChanges (33)
Full ContentAssetsAssets are any kind of file that may be downloaded to a client web browser in addition to the dynamically generated HTML. Assets are most often images, stylesheets, and _javascript_ libraries. Normal assets are stored in the web application's context folder ... stored inside the web application WAR file in the ordinary way. Tapestry will also make files stored on the classpath, with your Java class files, visible to the web browser. Assets are exposed to your code as instances of the Asset interface. Injecting AssetsComponents learn about assets via injection. The Inject annotation allows Assets to be injected into components as read-only properties. The path to the resource is specified using the Path annotation. @Inject @Path("context:images/tapestry_banner.gif") private Asset banner;
Performance NotesAssets are expected to be entirely static (not changing while the application is deployed). When Tapestry generates a URL for an asset, either on the classpath or from the context, the URL includes a version number. Further, the asset will get a far future expires header, which will encourage the client browser to cache the asset. In addition, Tapestry will GZIP compress the content of all assets (if the asset is compressable, and the client supports it). You should have an explicit application version number for any production application. Client browsers will aggressively cache downloaded assets; they will usually not even send a request to see if the asset has changed once the asset is downloaded the first time. Because of this is is very important that each new deployment of your application get a new version number: this will force existing clients to re-download all files.
Change Notification Preferences
View Online
|
View Changes
|
- [CONF] Apache Tapestry > Assets confluence
- [CONF] Apache Tapestry > Assets confluence
