There is no way to set `matchOptions` for `ExpirationPlugin` in generateSW
Brought to you by:
tomkozak
Originally created by: cawa-93
Library Affected:
workbox-build, generateSW
Browser & Platform:
"all browsers"
Issue or Feature Request Description:
There is no way to set matchOptions for ExpirationPlugin.
I can only specify these options at a higher level:
{
runtimeCaching: [
{
urlPattern: /^https:\/\/.../,
handler: 'CacheFirst',
options: {
cacheName: 'search-results',
expiration: {
maxAgeSeconds: 1,
},
matchOptions: {
ignoreVary: true,
},
},
},
]
}
But it will generate the following SW:
workbox.registerRoute(/^https:\/\/.../, new workbox.CacheFirst({
"cacheName": "search-results",
"matchOptions": {
"ignoreVary": true
},
plugins: [new workbox.ExpirationPlugin({
maxAgeSeconds: 1,
purgeOnQuotaError: true
})]
}), 'GET')
Note that matchOptions no are passed to the ExpirationPlugin. Expected result:
workbox.registerRoute(/^https:\/\/.../, new workbox.CacheFirst({
"cacheName": "search-results",
"matchOptions": {
"ignoreVary": true
},
plugins: [new workbox.ExpirationPlugin({
maxAgeSeconds: 1,
purgeOnQuotaError: true,
"matchOptions": {
"ignoreVary": true
},
})]
}), 'GET')
If I try to pass these options down:
{
runtimeCaching: [
{
urlPattern: /^https:\/\/.../,
handler: 'CacheFirst',
options: {
cacheName: 'search-results',
expiration: {
maxAgeSeconds: 1,
matchOptions: {
ignoreVary: true,
},
},
matchOptions: {
ignoreVary: true,
},
},
},
]
}
I will get an error:
ValidationError: "runtimeCaching[0].options.expiration.matchOptions" is not allowed
Originally posted by: jeffposnick
I just tested locally and confirmed that this should be resolved with [#2865].
Related
Tickets:
#2865Ticket changed by: jeffposnick