Skip to content

Serve images as WebP#4649

Open
mozzius wants to merge 4 commits intomainfrom
serve-images-as-webp
Open

Serve images as WebP#4649
mozzius wants to merge 4 commits intomainfrom
serve-images-as-webp

Conversation

@mozzius
Copy link
Member

@mozzius mozzius commented Feb 17, 2026

I won't pretend to be an expert at this part of the codebase, but the tests pass!

Summary

  • Switch image presets (avatar, banner, feed_thumbnail, feed_fullsize) from JPEG to WebP for better compression
  • Add WebP support to the sharp image processor
  • Include format in cache keys so JPEG and WebP variants are cached separately
  • Invalidate all format variants (jpeg, png, webp) on cache clear to ensure takedowns work across formats

Backward compatibility

Old URLs with @jpeg in the path continue to work — the format is parsed from the URL and overrides the preset default. The cache key now includes format, so old and new URLs are stored/served independently.

Note: If OZONE_CDN_PATHS templates are format-specific (e.g. contain @jpeg), the deployment config should be updated to include @webp variants so CDN invalidation covers new URLs.

Test plan

  • packages/bsky/tests/image/uri.test.ts — all 6 tests pass
  • Ensure this won't overload the server — I don't know how to verify this

🤖 Generated with Claude Code

mozzius and others added 4 commits February 17, 2026 19:40
Switch avatar, banner, feed_thumbnail, and feed_fullsize presets to
default to WebP for better compression. Existing URLs with @jpeg in the
path continue to work since the format is parsed from the URL and
overrides the preset default.

- Add WebP branch to sharp image processor
- Include format in cache keys to prevent collisions between formats
- Invalidate all format variants (jpeg, png, webp) on cache clear
- Accept webp as a valid format in URI path validation
- Update tests to reflect new default format

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix prettier formatting in uri.test.ts
- Update server.test.ts to expect image/webp instead of image/jpeg

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mozzius mozzius changed the title Serve image presets as WebP Serve images as WebP Feb 17, 2026
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.

1 participant