private void configureCaching ( HttpServletResponse response , int seconds ) { // HTTP 1.0 header response . setDateHeader ( HTTP_EXPIRES_HEADER , System . currentTimeMillis ( ) + seconds * 1000L ) ; if ( seconds > 0 ) { // HTTP 1.1 header response . setHeader ( HTTP_CACHE_CONTROL_HEADER , "max-age=" + seconds ) ; } else { // HTTP 1.1 header response . setHeader ( HTTP_CACHE_CONTROL_HEADER , "no-cache" ) ; } }
Set HTTP headers to allow caching for the given number of seconds .