unjs / ipx

๐Ÿ–ผ๏ธ High performance, secure and easy-to-use image optimizer.
MIT License
1.2k stars 59 forks source link

fix(server): set `cache-control` header only after processing image #200

Closed ucw closed 5 months ago

ucw commented 6 months ago

๐Ÿ”— Linked issue

โ“ Type of change

๐Ÿ“š Description

Currently, the Cache-Control header is set before image processing takes place. This can lead to the caching of a 500 error in Cloudflare if an exception occurs during image processing. The changes in this pull request move the setting of the Cache-Control header after the image processing to prevent the caching of 500 errors in such scenarios.

๐Ÿ“ Checklist

codecov[bot] commented 5 months ago

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (fc8a0de) 54.10% compared to head (873ecfa) 54.10%. Report is 4 commits behind head on main.

Files Patch % Lines
src/server.ts 0.00% 9 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #200 +/- ## ======================================= Coverage 54.10% 54.10% ======================================= Files 11 11 Lines 1083 1083 Branches 45 45 ======================================= Hits 586 586 Misses 497 497 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.