In keeping with good practices for speeding up websites, we wanted to set far future Expires headers on these static resources so that once the client populated their cache, there would no more requests for these resources.
The first step towards this was to add some directives to our apache httpd.conf that set the expires headers for us.
This would add an Expires header to each static resource that was requested with a date that was 1 year in the future.
<Location "cq/myapp/static">
ExpiresDefault "access plus 1 year"
</Location>
However, from time to time we make application releases which do change these "static" resources. For example, any change to the site's CSS design or javascript functionality would need to be represented immediately for users of the site.
To get around this we used the CQ4 mapper functionality to rewrite the resource URLs within the system to include the version number.
This adapted the URLs output from CQ templates from
/myapp/static/js/logo.png > /myapp/static/v.1.0.2/js/logo.png
All this means that a client with a populated cache will rarely request any of the static resources of the site unless they change, in which case they are requested immediately. This saves a tremendous amount of effort for the client browser, and the user experience of the site performance is greatly improved. These simple steps gave us great performance boost for very little effort.
