public static boolean isNotModified ( Context context , long lastModified , String etag ) { // First check etag. Important, if there is an If-None-Match header, we MUST not check the // If-Modified-Since header, regardless of whether If-None-Match matches or not. This is in // accordance with section 14.26 of RFC2616. final String browserEtag = context . header ( HeaderNames . IF_NONE_MATCH ) ; if ( browserEtag != null ) { // We check the given etag against the given one. // If the given one is null, that means that etags are disabled. return browserEtag . equals ( etag ) ; } // IF_NONE_MATCH not set, check IF_MODIFIED_SINCE final String ifModifiedSince = context . header ( HeaderNames . IF_MODIFIED_SINCE ) ; if ( ifModifiedSince != null && lastModified > 0 && ! ifModifiedSince . isEmpty ( ) ) { try { // We do a double check here because the time granularity is important here. // If the written date headers are still the same, we are unchanged (the granularity is the // second). return ifModifiedSince . equals ( DateUtil . formatForHttpHeader ( lastModified ) ) ; } catch ( IllegalArgumentException ex ) { LoggerFactory . getLogger ( CacheUtils . class ) . error ( "Cannot build the date string for {}" , lastModified , ex ) ; return true ; } } return false ; }
Check whether the request can send a NOT_MODIFIED response .