Skip to content

Conversation

@develop7
Copy link
Collaborator

@develop7 develop7 commented Jan 20, 2026

RFC: Introduces hardcoded (for now) Vary header for all responses. I'm almost certain the logic should be a bit more complex, so absolute do chime in when that's the case.

Fixes #133

@taimoorzaeem
Copy link
Collaborator

Linking the RFC 7231: Vary for reference.

@wolfgangwalther
Copy link
Member

From reading up on the RFC only a tiny bit it looks to me like... we might not actually need much more sophisticated logic.

Of course, it'd be great have some kind of sophisticated way of encoding, possibly in the haskell type system or so, which headers are in the list - instead of hardcoding them (and the forgetting to update the list accordingly when changes are made). But this might well be overengineering.

We should certainly not send this header only when we actually varied the response - this defeats the purpose of using this as a cache key on intermediates.

So.. this might already be close to "it"?

@develop7 develop7 marked this pull request as ready for review January 26, 2026 16:36
@develop7
Copy link
Collaborator Author

Let me update the changelog then

@develop7 develop7 force-pushed the feat-add_vary_header branch from acad7de to b9fd8d0 Compare January 26, 2026 16:40
@develop7
Copy link
Collaborator Author

BTW do I need tests?

@wolfgangwalther
Copy link
Member

There probably can't be tested much in a meaningful way here. Maybe you can add some expectations for these headers to an existing test somewhere.

Conflicted in the changelog.

toWaiResponse :: ServerTiming -> Response.PgrstResponse -> Wai.Response
toWaiResponse timing (Response.PgrstResponse st hdrs bod) = Wai.responseLBS st (hdrs ++ ([serverTimingHeader timing | configServerTimingEnabled])) bod
toWaiResponse timing (Response.PgrstResponse st hdrs bod) =
Wai.responseLBS st (hdrs ++ serverTimingHeaders timing ++ [varyHeader]) bod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is worth filtering hdrs to make sure Vary is not there.

Not sure what to do in such a case. Error out? Leave them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, I'd leave it as is

@develop7 develop7 force-pushed the feat-add_vary_header branch 2 times, most recently from e7f1909 to 4472cea Compare January 29, 2026 14:49
@taimoorzaeem
Copy link
Collaborator

BTW do I need tests?

It would be good to add at least one to prevent regression.

@develop7 develop7 force-pushed the feat-add_vary_header branch from 4472cea to 1163c19 Compare January 29, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

implement "Vary" headers and proper HEAD responses

4 participants