зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1267474 - cache-control: immutable 2/3 r=mayhemer
--HG-- extra : rebase_source : 5022699f221ecd3cb66336ef11c6863b89e8de88
This commit is contained in:
Родитель
7f770ceea1
Коммит
aaaa179e7c
|
@ -180,7 +180,7 @@ interface nsIRequest : nsISupports
|
|||
* cached content is automatically validated if necessary before reuse.
|
||||
*
|
||||
* VALIDATE_ALWAYS forces validation of any cached content independent of
|
||||
* its expiration time.
|
||||
* its expiration time (unless it is https with Cache-Control: immutable)
|
||||
*
|
||||
* VALIDATE_NEVER disables validation of cached content, unless it arrived
|
||||
* with the "Cache: no-store" header, or arrived via HTTPS with the
|
||||
|
|
|
@ -3407,6 +3407,13 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, nsIApplicationCache* appC
|
|||
bool isForcedValid = false;
|
||||
entry->GetIsForcedValid(&isForcedValid);
|
||||
|
||||
nsXPIDLCString framedBuf;
|
||||
rv = entry->GetMetaDataElement("strongly-framed", getter_Copies(framedBuf));
|
||||
// describe this in terms of explicitly weakly framed so as to be backwards
|
||||
// compatible with old cache contents which dont have strongly-framed makers
|
||||
bool weaklyFramed = NS_SUCCEEDED(rv) && framedBuf.EqualsLiteral("0");
|
||||
bool isImmutable = !weaklyFramed && isHttps && mCachedResponseHead->Immutable();
|
||||
|
||||
// Cached entry is not the entity we request (see bug #633743)
|
||||
if (ResponseWouldVary(entry)) {
|
||||
LOG(("Validating based on Vary headers returning TRUE\n"));
|
||||
|
@ -3432,7 +3439,7 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, nsIApplicationCache* appC
|
|||
}
|
||||
// If the VALIDATE_ALWAYS flag is set, any cached data won't be used until
|
||||
// it's revalidated with the server.
|
||||
else if (mLoadFlags & nsIRequest::VALIDATE_ALWAYS) {
|
||||
else if ((mLoadFlags & nsIRequest::VALIDATE_ALWAYS) && !isImmutable) {
|
||||
LOG(("Validating based on VALIDATE_ALWAYS load flag\n"));
|
||||
doValidation = true;
|
||||
}
|
||||
|
@ -3559,12 +3566,6 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, nsIApplicationCache* appC
|
|||
mCachedContentIsValid = !doValidation;
|
||||
|
||||
if (doValidation) {
|
||||
nsXPIDLCString buf;
|
||||
rv = entry->GetMetaDataElement("strongly-framed", getter_Copies(buf));
|
||||
// describe this in terms of explicitly weakly framed so as to be backwards
|
||||
// compatible with old cache contents which dont have strongly-framed makers
|
||||
bool weaklyFramed = NS_SUCCEEDED(rv) && buf.EqualsLiteral("0");
|
||||
|
||||
//
|
||||
// now, we are definitely going to issue a HTTP request to the server.
|
||||
// make it conditional if possible.
|
||||
|
@ -3576,12 +3577,12 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, nsIApplicationCache* appC
|
|||
// the request method MUST be either GET or HEAD (see bug 175641) and
|
||||
// the cached response code must be < 400
|
||||
//
|
||||
// the cached content must not be weakly framed
|
||||
// the cached content must not be weakly framed or marked immutable
|
||||
//
|
||||
// do not override conditional headers when consumer has defined its own
|
||||
if (!mCachedResponseHead->NoStore() &&
|
||||
(mRequestHead.IsGet() || mRequestHead.IsHead()) &&
|
||||
!mCustomConditionalRequest && !weaklyFramed &&
|
||||
!mCustomConditionalRequest && !weaklyFramed && !isImmutable &&
|
||||
(mCachedResponseHead->Status() < 400)) {
|
||||
|
||||
if (mConcurentCacheAccess) {
|
||||
|
|
|
@ -643,6 +643,7 @@ nsHttpResponseHead::Reset()
|
|||
mCacheControlPrivate = false;
|
||||
mCacheControlNoStore = false;
|
||||
mCacheControlNoCache = false;
|
||||
mCacheControlImmutable = false;
|
||||
mPragmaNoCache = false;
|
||||
mStatusText.Truncate();
|
||||
mContentType.Truncate();
|
||||
|
@ -812,6 +813,7 @@ nsHttpResponseHead::ParseCacheControl(const char *val)
|
|||
mCacheControlPrivate = false;
|
||||
mCacheControlNoCache = false;
|
||||
mCacheControlNoStore = false;
|
||||
mCacheControlImmutable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -827,6 +829,11 @@ nsHttpResponseHead::ParseCacheControl(const char *val)
|
|||
// search header value for occurrence of "no-store"
|
||||
if (nsHttp::FindToken(val, "no-store", HTTP_HEADER_VALUE_SEPS))
|
||||
mCacheControlNoStore = true;
|
||||
|
||||
// search header value for occurrence of "immutable"
|
||||
if (nsHttp::FindToken(val, "immutable", HTTP_HEADER_VALUE_SEPS)) {
|
||||
mCacheControlImmutable = true;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
, mCacheControlPrivate(false)
|
||||
, mCacheControlNoStore(false)
|
||||
, mCacheControlNoCache(false)
|
||||
, mCacheControlImmutable(false)
|
||||
, mPragmaNoCache(false) {}
|
||||
|
||||
const nsHttpHeaderArray & Headers() const { return mHeaders; }
|
||||
|
@ -47,6 +48,7 @@ public:
|
|||
bool Private() const { return mCacheControlPrivate; }
|
||||
bool NoStore() const { return mCacheControlNoStore; }
|
||||
bool NoCache() const { return (mCacheControlNoCache || mPragmaNoCache); }
|
||||
bool Immutable() const { return mCacheControlImmutable; }
|
||||
/**
|
||||
* Full length of the entity. For byte-range requests, this may be larger
|
||||
* than ContentLength(), which will only represent the requested part of the
|
||||
|
@ -133,6 +135,7 @@ public:
|
|||
mCacheControlPrivate == aOther.mCacheControlPrivate &&
|
||||
mCacheControlNoCache == aOther.mCacheControlNoCache &&
|
||||
mCacheControlNoStore == aOther.mCacheControlNoStore &&
|
||||
mCacheControlImmutable == aOther.mCacheControlImmutable &&
|
||||
mPragmaNoCache == aOther.mPragmaNoCache;
|
||||
}
|
||||
|
||||
|
@ -154,6 +157,7 @@ private:
|
|||
bool mCacheControlPrivate;
|
||||
bool mCacheControlNoStore;
|
||||
bool mCacheControlNoCache;
|
||||
bool mCacheControlImmutable;
|
||||
bool mPragmaNoCache;
|
||||
|
||||
friend struct IPC::ParamTraits<nsHttpResponseHead>;
|
||||
|
|
Загрузка…
Ссылка в новой задаче