Skip to content

Commit

Permalink
Set no-cache headers on pages with image transform generation URLs
Browse files Browse the repository at this point in the history
Resolves #16195
  • Loading branch information
brandonkelly committed Dec 10, 2024
1 parent 909770e commit d7dce98
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

## System
- Database rows with foreign keys referencing nonexistent rows are now deleted via garbage collection.
- Pages which contain image transform generation URLs now set no-cache headers. ([#16195](https://github.com/craftcms/cms/discussions/16195))
- Updated Twig to 3.15. ([#16207](https://github.com/craftcms/cms/discussions/16207))
3 changes: 3 additions & 0 deletions src/imagetransforms/ImageTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public function getTransformUrl(Asset $asset, ImageTransform $imageTransform, bo
'transformId' => $index->id,
]), 2048);

// Prevent the page from being cached
Craft::$app->getResponse()->setNoCacheHeaders();

// Return the temporary transform URL
return UrlHelper::actionUrl('assets/generate-transform', [
'transformId' => $index->id,
Expand Down

0 comments on commit d7dce98

Please sign in to comment.