Skip to content

Add Vary:Accept header to thumbs responses - #1335

Merged
JackLewis-digirati merged 4 commits into
developfrom
feature/varyAcceptHeader
Oct 29, 2026
Merged

JackLewis-digirati merged 4 commits into
developfrom
feature/varyAcceptHeader

Conversation

@JackLewis-digirati

@JackLewis-digirati JackLewis-digirati commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

What does this change?

Resolves #1336

This PR enables thumbs info json responses to send Vary: Accept headers, which was missed

@JackLewis-digirati

JackLewis-digirati commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

What this does

Thumbs info.json responses now send Vary: Accept-Encoding, Accept. Previously they sent only Vary: Accept-Encoding.

Why

When the request path has no /v2/ or /v3/ segment, Thumbs picks the IIIF Image API version from the Accept header (ThumbsMiddleware.DiscoverRequestedImageApiVersion). For v2, Accept also decides whether the Content-Type is application/ld+json or application/json.

Thumbs has UseResponseCaching() enabled with ResponseCacheSeconds: 60 (set in the base appsettings.json). ASP.NET's response cache stores a separate copy for each value of the headers listed in Vary. With only Accept-Encoding listed, it served whichever version was requested first to every client for 60s.

Confirmed live on prod: requests with */*, the v2 profile and the v3 profile all returned v2 with the same x-correlation-id, so they were one cached response. With the cache bypassed, the v3 request returned v3. This happens on both apex and CloudFront. CloudFront keys on Accept correctly, but on a miss it fetches from Thumbs and gets the cached response.

Orchestrator's description-resource endpoints (image info.json, single-item manifest, named query) already send Vary: Accept-Encoding, Accept via IIIFAssetControllerBase, and were confirmed working live.

Changes

  • Thumbs/ThumbsMiddleware.cs: add Accept to the Vary header in WriteInfoJson.
  • Tests: assert Vary contains Accept in the Thumbs InfoJsonTests (v2 direct path, v2 conneg, v3 conneg) and in the Orchestrator ImageHandlingTests v2/v3 conneg info.json tests, which weren't covered before.

After deploying

Nothing to clear: Thumbs' cache holds responses for 60s, so any wrong copies expire within a minute.

@JackLewis-digirati
JackLewis-digirati marked this pull request as ready for review October 28, 2026 11:11
@JackLewis-digirati
JackLewis-digirati requested a review from a team as a code owner October 28, 2026 11:11
@JackLewis-digirati
JackLewis-digirati merged commit be4208b into develop Oct 29, 2026
8 checks passed
@JackLewis-digirati
JackLewis-digirati deleted the feature/varyAcceptHeader branch October 29, 2026 17:18
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.

Vary: Accept header has been missed from thumbs paths

2 participants