STATIC_CONTENT_SERVER
This option specifies a base URL for static content such as images, CSS files and JavaScript files. The option enables the relocation of static content to a separate server to allow for performance optimizations.
<STATIC_CONTENT_SERVER> <URL>http://www.myserver.com/staticresources/</URL> </STATIC_CONTENT_SERVER>
The forward slash at the end of the URL in the example is optional. It is also possible to use a relative URL.
<STATIC_CONTENT_SERVER> <URL>/CuramStatic/</URL> </STATIC_CONTENT_SERVER>
Where this option is used, the static content can be packaged using the zip-static-content target available in the webclient project. This target will create a zip file, StaticContent.zip, in the webclient\build directory. The StaticContent.zip file will contain all relevant static content to be relocated when the STATIC_CONTENT_SERVER setting is enabled. The -Dstatic.content.zip setting can be used to overwrite the default zip location. All content in the zip is stored under a root folder called WebContent.
build zip-static-content -Dstatic.content.zip=<myzipfile.zip>
The following content is included in the zip file:
- WebContent/**/*.html
- WebContent/**/*.htm
- WebContent/CDEJ/**/*.png
- WebContent/CDEJ/**/*.gif
- WebContent/CDEJ/**/*.jpg
- WebContent/CDEJ/**/*.jpeg
- WebContent/CDEJ/**/*.ico
- WebContent/CDEJ/**/*.css
- WebContent/CDEJ/**/*.js
- WebContent/CDEJ/**/*.svg
- WebContent/CDEJ/jscript/**/*.*
- WebContent/CDEJ/themes/**/*.*
- WebContent/Images/**/*.*
- WebContent/genImages/**/*.*
- WebContent/themes/**/*.*
The relocation of static content to a separate server allows for specific cache control response headers to be set for this content. Setting a cache control response header provides an instruction to the browser to cache this content for a period of time; the aim of which is to reduce network traffic and improve performance. The Expires and Cache-control headers are generally recommended to encourage the browser to cache static content.
Expires: Thu, 15 Apr 2010 20:00:00 GMT Cache-control: max-age=86400
Note: The Expires value must match the specific formatting above to be recognized. The max-age attribute value is in seconds.
When the above headers are set the browser will cache the content until the max-age value is reached or the Expires date is reached. When cached, no request will be made to the server.
It is worth noting that there are exceptions to this, which can be browser dependent. A key exception is on a user triggered refresh (F5); Internet Explorer and Chrome will both perform conditional requests for all content in this instance, regardless of the freshness of the content in the cache. A conditional request is a request to determine if the resource has been modified and will usually result in a 304 response, which will be faster than a full resource request (200 response).