-
Notifications
You must be signed in to change notification settings - Fork 822
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
Adds cacheKeyWillBeUsed lifecycle callback #1990
Conversation
@@ -366,5 +443,78 @@ describe(`cacheWrapper`, function() { | |||
expect(spyOne.callCount).to.equal(1); | |||
expect(spyTwo.callCount).to.equal(1); | |||
}); | |||
|
|||
it(`should call cacheKeyWillBeUsed`, async function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeat code? Looks like these two tests are the same as the ones above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're in different describe()
blocks—one for .put()
and the other for .match()
. The actual test cases are different, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In particular, the tests confirm that the correct mode
value ('read'
or 'write'
) is passed in to the plugin, and that the underlying cache.match()
or cache.put()
operation is actually called with the plugin's return value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I see. I couldn't easily see the outer blocks from the diff.
PR-Bot Size PluginChanged File Sizes
New FilesNo new files have been added. All File SizesView Table
Workbox Aggregate Size Plugin8.86KB gzip'ed (59% of limit) |
R: @philipwalton
Fixes #1709
This adds a new
cacheKeyWillBeUsed
lifecycle callback, following the interface described at #1709 (comment). This allows developers to override the default cache key for reads or writes (or both), for requests that pass through ourcacheWrapper
interface.Once it's released, we'll need to update https://developers.google.com/web/tools/workbox/guides/using-plugins with info on usage.