Cache not working as expected
See original GitHub issueusing .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.
Expected Behavior
The url should not be striped away from the query parameters.
Current Behavior
If we have http://google.com?someKey=123, the end result that is used as a key cache is http://google.com
Possible Solution
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?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- 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 calltoCanvas
a second time.