Skip to content

Invalidate presigned URLs' cache - #169

Open
evabanova wants to merge 4 commits into
mainfrom
fix/invalidate-presigned-url
Open

evabanova wants to merge 4 commits into
mainfrom
fix/invalidate-presigned-url

Conversation

@evabanova

Copy link
Copy Markdown
Collaborator

The issue: When an item is updated, new thumbnail is being generated and updated as an S3 object. However presigned URLS to S3 are being cached and are pointing to the old version of the thumbnail.

Example scenario: change an item of a tapestry, go to the dashboard without refresh - the old thumbnail before the changes is shown.

Fix: Invalidate the presigned URLs. After every change to S3 object, we delete the presigned URL from the cache so a new one must be generated.

Note: On the above test scenario, there is a slight delay to thumbnail change, until the worker generates the new thumbnail.

Comment thread server/src/services/redis.ts Outdated
const namespacedKey = this.namespacedKey(key)
//we have to remove the marker as well or it will pass to the new url
keysToDelete.push(namespacedKey, this.validationKey(namespacedKey))
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be shortened a bit

const toDelete = keys.flatMap(k => {
  const namespacedKey = this.namespacedKey(key)
  return [namespacedKey, this.validationKey(namespacedKey)]
})

Sachanski
Sachanski previously approved these changes Oct 26, 2026
Sachanski
Sachanski previously approved these changes Oct 26, 2026
Comment thread server/src/services/s3-service.ts Outdated
Comment thread server/src/services/redis.ts Outdated
Comment thread server/src/services/redis.ts Outdated
async delete(key: string) {
await redis.del(this.namespacedKey(key))
async delete(...keys: string[]) {
const toDelete = keys.flatMap((key) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we can change this to keys.flatMap((key) => [this.namespacedKey(key), this.validationKey(key)])

This branch has not been deployed

No deployments
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 this pull request may close these issues.

3 participants