-
Notifications
You must be signed in to change notification settings - Fork 663
Why we not use the full image url as cache key? #206
Copy link
Copy link
Closed
Description
The logic of caching image url is not working as expected
See here the source code of the issue https://github.com/bubkoo/html-to-image/blob/master/src/getBlobFromURL.ts#:~:text=let%20key%20%3D%20url.replace(/%5C%3F.*/%2C%20%27%27)
function getCacheKey(url: string) {
let key = url.replace(/\?.*/, '')
// font resourse
if (/ttf|otf|eot|woff2?/i.test(key)) {
key = key.replace(/.*\//, '')
}
return key
}If the image use query string to distinguish which image to get, that image all same format image with used the wrong cached one.
For example:
The second one will render with the first image because of the cache logic
Expected Behavior
We should use the full URL as key to cache.
Current Behavior
It only use the URL with domain and path, not query string.
Possible Solution
Remove let key = url.replace(/\?.*/, '')
Your Environment
- html-to-image: 1.9.0
- OS: Win10
- Browser: chrome
Reactions are currently unavailable