cache-handler icon indicating copy to clipboard operation
cache-handler copied to clipboard

Header normalization

Open cdaguerre opened this issue 1 year ago • 2 comments

Hi, I'm looking for some guidance on Accept-Language and Accept-Encoding header normalization to avoid high cache key cardinality.

For encoding, I was thinking of something like:

map {header.Accept-Encoding} {accept} {
	~br      br
	~gzip    gzip
	default  *
}

request_header Accept-Encoding {accept}

And for Accept-Language I was looking at https://github.com/simia-tech/caddy-locale but it doesn't seem to work with caddy 2.

Do you have recommendations? Is this even necessary?

cdaguerre avatar Dec 12 '24 11:12 cdaguerre

Hello @cdaguerre that's something I would like to implement in the cache-handler/souin but I didn't find a way to do that without impacting the performances.

darkweak avatar Dec 22 '24 19:12 darkweak

Hi @darkweak If it helps, I wrote a locale normalization plugin for caddy 2 here: https://github.com/cdaguerre/caddy-locale

Using it with following config normalizes and overwrites the Accept-Language header.

locale en fr de {
  header Accept-Language 
}

But I have no clue of the performance impact... And for encoding, I'm more or less using what I pasted in the issue description above.

cdaguerre avatar Dec 23 '24 08:12 cdaguerre