lib/helper.js
function isFreshEnough(entry, req)
{
    // If no cache-control header in request, then entry is fresh
    // if it hasn't expired.
    if (!("cache-control" in req.headers)) {
        return new Date().getTime() < entry.expires;
    }

    var headers = parseHeader(req.headers["cache-control"]);

    if ("must-revalidate" in headers) {
        return false;
    } else if ("max-stale" in headers) {
        // TODO Tell the client that the resource is stale, as RFC2616 requires
        return !headers["max-stale"] || ((headers["max-stale"] * 1000) > (new Date().getTime() - entry.expires)); // max-stale > "staleness"
    } else if ("max-age" in headers) {
        return (headers["max-age"] * 1000) > (new Date().getTime() - entry.created); // max-age > "age"
    } else if ("min-fresh" in headers) {
        return (headers["min-fresh"] * 1000) < (entry.expires - new Date().getTime()); // min-fresh < "time until expiry"
    } else {
        return new Date().getTime() < entry.expires;
    }

}
function isFreshEnough(entry, req)
{
    // If no cache-control header in request, then entry is fresh
    // if it hasn't expired.
    if (!("cache-control" in req.headers)) {
        return new Date().getTime() < entry.expires;
    }

    var headers = parseHeader(req.headers["cache-control"]);

    if ("must-revalidate" in headers) {
        return false;
    } else if ("max-stale" in headers) {
        // TODO Tell the client that the resource is stale, as RFC2616 requires
        return !headers["max-stale"] || ((headers["max-stale"] * 1000) > (new Date().getTime() - entry.expires)); // max-stale > "staleness"
    } else if ("max-age" in headers) {
        return (headers["max-age"] * 1000) > (new Date().getTime() - entry.created); // max-age > "age"
    } else if ("min-fresh" in headers) {
        return (headers["min-fresh"] * 1000) < (entry.expires - new Date().getTime()); // min-fresh < "time until expiry"
    } else {
        return new Date().getTime() < entry.expires;
    }

}
function isFreshEnough ( entry , req ) { // If no cache-control header in request, then entry is fresh // if it hasn't expired. if ( ! ( "cache-control" in req . headers ) ) { return new Date ( ) . getTime ( ) < entry . expires ; } var headers = parseHeader ( req . headers [ "cache-control" ] ) ; if ( "must-revalidate" in headers ) { return false ; } else if ( "max-stale" in headers ) { // TODO Tell the client that the resource is stale, as RFC2616 requires return ! headers [ "max-stale" ] || ( ( headers [ "max-stale" ] * 1000 ) > ( new Date ( ) . getTime ( ) - entry . expires ) ) ; // max-stale > "staleness" } else if ( "max-age" in headers ) { return ( headers [ "max-age" ] * 1000 ) > ( new Date ( ) . getTime ( ) - entry . created ) ; // max-age > "age" } else if ( "min-fresh" in headers ) { return ( headers [ "min-fresh" ] * 1000 ) < ( entry . expires - new Date ( ) . getTime ( ) ) ; // min-fresh < "time until expiry" } else { return new Date ( ) . getTime ( ) < entry . expires ; } }
true if the candidate reponse satisfies the request in terms of freshness, otherwise false.
true if the candidate reponse satisfies the request in terms of freshness otherwise false .