private void cacheResponseInfo ( final httpClientInteraction method , final File cacheFile ) { //write cache data to file if present Properties newprops = new Properties ( ) ; if ( null != method . getResponseHeader ( LAST_MODIFIED ) ) { newprops . setProperty ( LAST_MODIFIED , method . getResponseHeader ( LAST_MODIFIED ) . getValue ( ) ) ; } if ( null != method . getResponseHeader ( E_TAG ) ) { newprops . setProperty ( E_TAG , method . getResponseHeader ( E_TAG ) . getValue ( ) ) ; } if ( null != method . getResponseHeader ( CONTENT_TYPE ) ) { newprops . setProperty ( CONTENT_TYPE , method . getResponseHeader ( CONTENT_TYPE ) . getValue ( ) ) ; } if ( newprops . size ( ) > 0 ) { try { final FileOutputStream fileOutputStream = new FileOutputStream ( cacheFile ) ; try { newprops . store ( fileOutputStream , "URLFileUpdater cache data for URL: " + url ) ; } finally { fileOutputStream . close ( ) ; } } catch ( IOException e ) { logger . debug ( "Failed to write cache header info to file: " + cacheFile + ", " + e . getMessage ( ) , e ) ; } } else if ( cacheFile . exists ( ) ) { if ( ! cacheFile . delete ( ) ) { logger . warn ( "Unable to delete cachefile: " + cacheFile . getAbsolutePath ( ) ) ; } } }
Cache etag and last - modified header info for a response