Skip to content

Commit 7d10e1b

Browse files
authored
templates: add cache tag to images so that they can be revalidated along with the page on website templates (#10647)
Previously images would not be revalidated if they were cropped or changed in another ways. Now if the image is updated, they will also be updated on the frontend whenever a post is revalidated.
1 parent 64fc2df commit 7d10e1b

File tree

2 files changed

+6
-2
lines changed
  • templates
    • website/src/components/Media/ImageMedia
    • with-vercel-website/src/components/Media/ImageMedia

2 files changed

+6
-2
lines changed

templates/website/src/components/Media/ImageMedia/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export const ImageMedia: React.FC<MediaProps> = (props) => {
4747
height = fullHeight!
4848
alt = altFromResource || ''
4949

50-
src = `${getClientSideURL()}${url}`
50+
const cacheTag = resource.updatedAt
51+
52+
src = `${getClientSideURL()}${url}?${cacheTag}`
5153
}
5254

5355
const loading = loadingFromProps || (!priority ? 'lazy' : undefined)

templates/with-vercel-website/src/components/Media/ImageMedia/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export const ImageMedia: React.FC<MediaProps> = (props) => {
4747
height = fullHeight!
4848
alt = altFromResource || ''
4949

50-
src = `${getClientSideURL()}${url}`
50+
const cacheTag = resource.updatedAt
51+
52+
src = `${getClientSideURL()}${url}?${cacheTag}`
5153
}
5254

5355
const loading = loadingFromProps || (!priority ? 'lazy' : undefined)

0 commit comments

Comments
 (0)