mirror of https://github.com/webpack/webpack.git
Merge pull request #15370 from webpack/fix/partial-15366
fix cache invalidation in HttpUriPlugin
This commit is contained in:
commit
4edf949da3
|
|
@ -509,7 +509,7 @@ class HttpUriPlugin {
|
|||
|
||||
/**
|
||||
* @param {string} url URL
|
||||
* @param {FetchResult} cachedResult result from cache
|
||||
* @param {FetchResult | RedirectFetchResult} cachedResult result from cache
|
||||
* @param {function((Error | null)=, FetchResult=): void} callback callback
|
||||
* @returns {void}
|
||||
*/
|
||||
|
|
@ -603,9 +603,30 @@ class HttpUriPlugin {
|
|||
res.statusCode >= 301 &&
|
||||
res.statusCode <= 308
|
||||
) {
|
||||
return finishWith({
|
||||
const result = {
|
||||
location: new URL(location, url).href
|
||||
});
|
||||
};
|
||||
if (
|
||||
!cachedResult ||
|
||||
!("location" in cachedResult) ||
|
||||
cachedResult.location !== result.location ||
|
||||
cachedResult.validUntil < validUntil ||
|
||||
cachedResult.storeLock !== storeLock ||
|
||||
cachedResult.storeCache !== storeCache ||
|
||||
cachedResult.etag !== etag
|
||||
) {
|
||||
return finishWith(result);
|
||||
} else {
|
||||
logger.debug(`GET ${url} [${res.statusCode}] (unchanged)`);
|
||||
return callback(null, {
|
||||
...result,
|
||||
fresh: true,
|
||||
storeLock,
|
||||
storeCache,
|
||||
validUntil,
|
||||
etag
|
||||
});
|
||||
}
|
||||
}
|
||||
const contentType = res.headers["content-type"] || "";
|
||||
const bufferArr = [];
|
||||
|
|
|
|||
|
|
@ -19,10 +19,6 @@ describeCases({
|
|||
/^Pack got invalid because of write to: Compilation\/modules.+loaders[/\\]options[/\\]error1\.js$/,
|
||||
/^Pack got invalid because of write to: Compilation\/modules.+loaders[/\\]options[/\\]error2\.js$/
|
||||
]
|
||||
},
|
||||
["asset-modules"]: {
|
||||
["http-url"]:
|
||||
/^Pack got invalid because of write to: webpack\.HttpUriPlugin|https:\/\/raw.githubusercontent.com\/\/webpack\/\/webpack\/\/main\/CODE_OF_CONDUCT\.md$/
|
||||
}
|
||||
},
|
||||
cache: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue