shorthash can generate the same identifier for different URLs
eatyourgreens opened this issue · 2 comments
eatyourgreens commented
Hi,
I'm using this plugin to cache API responses and I've run into a problem where, occasionally, a URL will resolve to the wrong resource from our database.
The problem seems to occur here, where shorthash
is used to generate the cache ID.
https://github.com/11ty/eleventy-cache-assets/blob/4ff6669de4fecba7b74cb46decb91e890c89693d/src/RemoteAssetCache.js#L12
Logging a couple of the problem URLs from out API, here's the URL, shorthash(URL)
and the resolved resource ID. The second subject ASC0000q71
resolves as subject ASC0000qu3
.
https://api.zooniverse.org/projects/illustratedlife/talk/subjects/ASC0000qu3, bc88de75, ASC0000qu3
https://api.zooniverse.org/projects/illustratedlife/talk/subjects/ASC0000q71, bc88de75, ASC0000qu3
eatyourgreens commented
Would passing in an optional ID, that overrides the hash, be a useful fix? I'm thinking of trying something like this for our project.
let url = 'https://api.zooniverse.org/projects/illustratedlife/talk/subjects/ASC0000q71';
let subjectData = await CacheAsset(url, {
id: 'ASC0000q71',
duration: "1d";
type: 'json'
});
zachleat commented
Merged, shipping with 3.0.0