Skip to content
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

shorthash can generate the same identifier for different URLs #7

Closed
eatyourgreens opened this issue Jun 16, 2020 · 2 comments · Fixed by #8
Closed

shorthash can generate the same identifier for different URLs #7

eatyourgreens opened this issue Jun 16, 2020 · 2 comments · Fixed by #8
Milestone

Comments

@eatyourgreens
Copy link
Contributor

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
Copy link
Contributor Author

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 zachleat added this to the v3.0.0 milestone Feb 25, 2022
@zachleat
Copy link
Member

Merged, shipping with 3.0.0

zachleat added a commit that referenced this issue Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants