Skip to content

Commit

Permalink
always use max-age if exists following 1.1 spec
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed May 20, 2013
1 parent 1ddc98a commit 3ac8b88
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/common/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,14 @@ YSLOW.Component.prototype.populateProperties = function (resolveRedirect, ignore
that.uncompressed_size = that.body.length;

// expiration based on either Expires or Cache-Control headers
expires = that.headers.expires;
if (expires && expires.length > 0) {
// set expires as a JS object
that.expires = new Date(expires);
if (that.expires.toString() === 'Invalid Date') {
that.expires = that.getMaxAge();
}
} else {
// always use max-age if exists following 1.1 spec
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.3
if (that.getMaxAge() !== undefined) {
that.expires = that.getMaxAge();
}
else if (that.headers.expires && that.headers.expires.length > 0) {
that.expires = new Date(that.headers.expires);
}

// compare image original dimensions with actual dimensions, data uri is
// first attempted to get the orginal dimension, if it fails (btoa) then
Expand Down

0 comments on commit 3ac8b88

Please sign in to comment.