-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
urlPattern doesn't work as expected #22
Comments
@artm4r you can use callback approach instead regex (this is via custom sw not using registerRoute(
({ url }) => url.pathname.startsWith(`${WPJsonUrl}/posts`),
new StaleWhileRevalidate({
cacheName: 'test-categories',
plugins: [
new CacheableResponsePlugin({ statuses: [0, 200] }),
new ExpirationPlugin({ maxEntries: 1, maxAgeSeconds: 10 * 24 * 60 * 60 }),
],
}),
) |
@userquin So I'll need to use InjectManifest? |
@artm4r no, wait preparing example... |
@artm4r try this one: {
urlPattern: new RegExp(`^${WPJsonUrl}/posts.*`, 'i'),
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'test-categories',
expiration: {
maxEntries: 1,
maxAgeSeconds: 10 * 24 * 60 * 60
},
cacheableResponse: {
statuses: [0, 200],
},
},
}, |
@userquin Thanks a lot! Now it works |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have this rule for one of
runtimeCaching
rules in config. If request is without query all works, but if I add query to request string - caching isn't working{ urlPattern: '${WPJsonUrl}/posts', handler: 'StaleWhileRevalidate', method: 'GET', options: { cacheName: 'test-categories', expiration: { maxEntries: 1, maxAgeSeconds: 10 * 24 * 60 * 60, }, cacheableResponse: { statuses: [0, 200] }, }, },
I tryed to write string like
${WPJsonUrl}/posts.*
, but nothing changed.If string in browser request will be like
/posts?page=1&per_page=7&_embed=true
caching will not work=(I think problem is that regex isn't working with the
urlPattern
property.In my nuxt2 project
urlPattern: ${WPJsonUrl}/posts
worked fineThe text was updated successfully, but these errors were encountered: