Cache not working as expectedSee original GitHub issue
.toPng method with cacheBust
true should not cache the image, unfortunately if the url stays the same and only the query parameters changes,
let key = url.replace(/\?.*/, '') this line from
src/getBlobFromURL.ts strips away all query parameters and implicitly it caches if the domain stays the same.
The url should not be striped away from the query parameters.
If we have http://google.com?someKey=123, the end result that is used as a key cache is
We can add a option to
ignoreQueryParams which will be
true by default. But when we need query params to be included in cache key, we can use
ignoreQueryParams: false to use all url.
- Use an array of images that lives under the same domain, changing them only by query parameters
- Switch pages. Personally I used React Router, but I suppose every SPA router will do the trick
- Notice how the image gets cached
I can open a PR with the fixed I mentioned above if that’s ok? What do you guys think about this?
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
The PR is still open and the issue is still happening
encountered this problem today. I’m using Next.js’s
Image component which caches images on the server as URL query param. Therefore the image is not getting re-rendered when I call
toCanvas a second time.