@ Nonnull public final UnifiedResponse enableCaching ( @ Nonnegative final int nSeconds ) { ValueEnforcer . isGT0 ( nSeconds , "Seconds" ) ; // Remove any eventually set headers // Note: don't remove Last-Modified and ETag! removeExpires ( ) ; removeCacheControl ( ) ; m_aResponseHeaderMap . removeHeaders ( CHttpHeader . PRAGMA ) ; if ( m_eHttpVersion . is10 ( ) ) { m_aResponseHeaderMap . setDateHeader ( CHttpHeader . EXPIRES , PDTFactory . getCurrentLocalDateTime ( ) . plusSeconds ( nSeconds ) ) ; } else { final CacheControlBuilder aCacheControlBuilder = new CacheControlBuilder ( ) . setPublic ( true ) . setMaxAgeSeconds ( nSeconds ) ; setCacheControl ( aCacheControlBuilder ) ; } return this ; }
Enable caching of this resource for the specified number of seconds .