mariusor,
@mariusor@metalhead.club avatar

Another small win today.

, the single user federated instance based on , serves HTML and 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! :D

I'm a little bit ashamed of myself that I've forgotten about it.

hypolite,

@mariusor Coincidentally enough, we had the same issue recently in #Friendica : github.com/friendica/friendica…

mariusor,
@mariusor@metalhead.club avatar

@hypolite old things are new again. :D Old knowledge resurrected.

hypolite,

@mariusor The issue only cropped up with some reverse proxies which none of the main devs use on their node 🤷‍♂️

mariusor,
@mariusor@metalhead.club avatar

@hypolite 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

mariusor,
@mariusor@metalhead.club avatar

@hypolite I am probably wrong and vary: accept works fine for proxies. My reasoning above might be correct only for user-agents...

hypolite,

@mariusor 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.

hypolite,

@mariusor 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.

mariusor, (edited )
@mariusor@metalhead.club avatar

@hypolite 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.

hypolite,

@mariusor Now I’m super glad I pointed out the coincidence in Friendica! 😄

mariusor,
@mariusor@metalhead.club avatar

@hypolite now I ended up wondering how I ended up deciding that the Content-Type is the header value in vary, not Accept.... grrrr.

mariusor,
@mariusor@metalhead.club avatar

@hypolite 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 :
https://marius.federated.id/outbox/1/object

hypolite,

@mariusor Thank you for the suggestion, I’ll pass it along to @heluecht who is the most knowledgeable in protocol implementation.

rmdes,
@rmdes@mstdn.social avatar

@mariusor damn you're in rampage fixing mode! It's beautiful to watch you at work!

mariusor,
@mariusor@metalhead.club avatar

@rmdes I'm coming back from a bout of cold, maybe my brain had time to recover while I spent two days sleeping on the couch with fever. :D

  • All
  • Subscribed
  • Moderated
  • Favorites
  • fediverse
  • DreamBathrooms
  • mdbf
  • ethstaker
  • magazineikmin
  • GTA5RPClips
  • rosin
  • thenastyranch
  • Youngstown
  • osvaldo12
  • slotface
  • khanakhh
  • kavyap
  • InstantRegret
  • Durango
  • provamag3
  • everett
  • cisconetworking
  • Leos
  • normalnudes
  • cubers
  • modclub
  • ngwrru68w68
  • tacticalgear
  • megavids
  • anitta
  • tester
  • JUstTest
  • lostlight
  • All magazines