Content Delivery API - Missing Accept-Language in Vary header #17953
Replies: 8 comments
-
Hi there @jdpnielsen! Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better. We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.
We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
Beta Was this translation helpful? Give feedback.
-
Not directly related to this issue is umbraco/Umbraco.Cloud.Issues#815, which also requests improvements to |
Beta Was this translation helpful? Give feedback.
-
@jdpnielsen did you find solution for this issue? I have the same problem - Accept-Language is not working and content is cached via all cultures. |
Beta Was this translation helpful? Give feedback.
-
@gogolineq Yes, actually. If you add a fake query parameter to your request, the browser will correctly match the cache entry. Ie. something like this:
|
Beta Was this translation helpful? Give feedback.
-
@jdpnielsen it's working, thanks! |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, Thank you for this ... and sorry for the belated response. I think this would be a great addition. But as this is a feature request, I will move this to the discussions for the time being 👍 You can roll your own solution with a piece of middleware. This way you don't have to add additional query parameters to the API calls: public class AddVaryHeaderMiddleware
{
private readonly RequestDelegate _next;
public AddVaryHeaderMiddleware(RequestDelegate next)
=> _next = next;
public async Task InvokeAsync(HttpContext context)
{
// add the Vary headers you need
context.Response.Headers["Vary"] = "Accept, Accept-Language";
await _next(context);
}
} |
Beta Was this translation helpful? Give feedback.
-
PR in #17962 |
Beta Was this translation helpful? Give feedback.
-
Will be included in 13.6 and 15.2 👍 |
Beta Was this translation helpful? Give feedback.
-
Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
13.4.1
Bug summary
I'm using the Content Delivery API with a multi-language site. When getting content in a specific language i use the
Accept-Language
header as specified in the documentation. Unfortunately, this can lead to issues with browser caching of content, due to the response being cached and served across any language variation. This happens because the browser does not take request headers into account when determining matching cache entries.Specifics
Screen recording shows issue with browser caching of requests, using the appended reproduction example:
Screen.Recording.2024-09-10.at.12.02.58.mov
Steps to reproduce
Accept-Language
header to get content in a specific language.Accept-Language
headerExpected result / actual result
A standard solution to this is for the server to respond to a request with the Vary header. Unfortunately it seems to be configured to respond with
Vary: Accept-Encoding
(At least on Umbraco Cloud).I propose two solutions:
Accept-Language
,Preview
andStart-Item
in theVary
header where applicable.https://localhost:44321/umbraco/delivery/api/v2/content?filter=contentType:eventEntity&language=da-DK
Beta Was this translation helpful? Give feedback.
All reactions