Skip to main content


Another small win today.

#Oni, the single user federated instance based on #GoActivityPub, serves HTML and #ActivityPub content from the same URLs based on what the clients request.

Firefox was caching the responses without taking into consideration the Content-Type, and was serving the JSON instead of HTML if refreshing a page. Only today I was reminded of the Vary header and fixed the problem. Yay! 😁

I'm a little bit ashamed of myself that I've forgotten about it.
old things are new again. 😁 Old knowledge resurrected.
@m😛etagram:rius The issue only cropped up with some reverse proxies which none of the main devs use on their node 🤷‍♂️
and are you guys sure it's the Accept header that needs to be taken into account for caching and not Content-Type ?

Vary is supposed to contain a list of the headers that the proxy/user-agent need to take into account when constructing the hash key for storing resources. Usually it's just the URL, vary adds a new element in the matrix for each header that it includes.

Accept is a request header, so I suspect that a vary with it will have no effect.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary
I am probably wrong and vary: accept works fine for proxies. My reasoning above might be correct only for user-agents...
@m😛etagram:rius From what I know reverse proxies insert themselves between clients and servers. The Vary header is used by the proxy from the server to figure out what requests from the client will trigger a cache hit or a miss. In this context, it has to be a client header (here Accept) because the proxy cannot know whether there are multiple Content-Type values for the same URL from the server.
@m😛etagram:rius Thinking more about it, I believe it’s the same for browsers, they need to know what request headers will produce different renditions of the same URL to be able to correctly cache it.
yes, I've tested with my production environment and vary: accept works as expected, but vary: content-type doesn't.

I wonder if I gaslit myself, or I had different tests in my dev environment.
This entry was edited (1 year ago)
@m😛etagram:rius Now I’m super glad I pointed out the coincidence in Friendica! 😄
if I can make a suggestion, you should return raw images for Image type objects if you save them on Friendica.

I like this feature a lot in #oni:
https://marius.federated.id/outbox/1/object
@m😛etagram:rius Thank you for the suggestion, I’ll pass it along to @Michael Vogel who is the most knowledgeable in protocol implementation.