@ Override public String getTag ( ) throws IOException { URLConnection urlConnection = url . openConnection ( ) ; String tag = urlConnection . getHeaderField ( ETAG ) ; if ( tag == null ) { String key = url . toString ( ) + "@" + urlConnection . getLastModified ( ) ; tag = md5Cache . getIfPresent ( key ) ; if ( tag == null ) { try ( InputStream urlStream = urlConnection . getInputStream ( ) ) { byte [ ] data = ByteStreams . toByteArray ( urlConnection . getInputStream ( ) ) ; tag = Hashing . md5 ( ) . hashBytes ( data ) . toString ( ) ; md5Cache . put ( key , tag ) ; } } } return tag ; }
Gets the tag using either the ETAG header of the URL connection or calculates it and caches it based on the URL & last modified date