Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve headers in PrecacheCacheKeyPlugin #2914

Merged
merged 2 commits into from
Aug 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions packages/workbox-precaching/src/utils/PrecacheCacheKeyPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,16 @@ class PrecacheCacheKeyPlugin implements WorkboxPlugin {
params,
}: WorkboxPluginCallbackParam['cacheKeyWillBeUsed']) => {
// Params is type any, can't change right now.
// eslint-disable-next-line
const cacheKey = params && params.cacheKey ||
this._precacheController.getCacheKeyForURL(request.url);

return cacheKey ? new Request(cacheKey) : request;
}
/* eslint-disable */
const cacheKey =
params?.cacheKey ||
this._precacheController.getCacheKeyForURL(request.url);
/* eslint-enable */

return cacheKey
? new Request(cacheKey, {headers: request.headers})
: request;
};
}

export {PrecacheCacheKeyPlugin};