public static void setClientCacheAggressively(HttpHeaders headers) {
        if (!headers.contains(CACHE_CONTROL)) {
            headers.set(CACHE_CONTROL, "public, " + MAX_AGE + "=" + SECS_IN_A_YEAR);
        }

        // CORS:
        // http://sockjs.github.com/sockjs-protocol/sockjs-protocol-0.3.3.html#section-7
        if (!headers.contains(ACCESS_CONTROL_MAX_AGE)) {
            headers.set(ACCESS_CONTROL_MAX_AGE, SECS_IN_A_YEAR);
        }

        // Note that SECS_IN_A_YEAR * 1000 is different from SECS_IN_A_YEAR * 1000L
        // because of integer overflow!
        if (!headers.contains(EXPIRES)) {
            headers.set(EXPIRES, formatRfc2822(System.currentTimeMillis() + SECS_IN_A_YEAR * 1000L));
        }
    }
public static void setClientCacheAggressively ( HttpHeaders headers ) { if ( ! headers . contains ( CACHE_CONTROL ) ) { headers . set ( CACHE_CONTROL , "public, " + MAX_AGE + "=" + SECS_IN_A_YEAR ) ; } if ( ! headers . contains ( ACCESS_CONTROL_MAX_AGE ) ) { headers . set ( ACCESS_CONTROL_MAX_AGE , SECS_IN_A_YEAR ) ; } if ( ! headers . contains ( EXPIRES ) ) { headers . set ( EXPIRES , formatRfc2822 ( System . currentTimeMillis ( ) + SECS_IN_A_YEAR * 1000L ) ) ; } }
Tells the browser to cache static files for a long time.
This works well even when this is a cluster of web servers behind a load balancer
because the URL created by urlForResource is in the form: resource?etag

<p>Don't worry that browsers do not pick up new files after you modified them,
see the doc about static files.

<p>Google recommends 1 year:
http://code.google.com/speed/page-speed/docs/caching.html

<p>Both Max-age and Expires header are set because IEs use Expires, not max-age:
http://mrcoles.com/blog/cookies-max-age-vs-expires/