long getCacheTimeInSec ( HttpHeaders httpHeaders ) { long cacheTimeInSec = 0 ; if ( httpHeaders . getCacheControl ( ) != null ) { for ( String arg : httpHeaders . getCacheControl ( ) . split ( "," ) ) { Matcher m = MAX_AGE_PATTERN . matcher ( arg ) ; if ( m . matches ( ) ) { cacheTimeInSec = Long . parseLong ( m . group ( 1 ) ) ; break ; } } } if ( httpHeaders . getAge ( ) != null ) { cacheTimeInSec -= httpHeaders . getAge ( ) ; } return Math . max ( 0 , cacheTimeInSec ) ; }
Gets the cache time in seconds . max - age in Cache - Control header and Age header are considered .