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.
ExpiresDefault "access plus 1 year"
To get around this we used the CQ4 mapper functionality to rewrite the resource URLs within the system to include the version number.
This meant changing the /config/delivery/mapper_live_publish.xml file to contain the following mapping:
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.