Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable cache control when caching endpoints #2774

Open
pdeveltere opened this issue Aug 1, 2024 · 0 comments
Open

Option to disable cache control when caching endpoints #2774

pdeveltere opened this issue Aug 1, 2024 · 0 comments
Assignees

Comments

@pdeveltere
Copy link

pdeveltere commented Aug 1, 2024

Is your feature request related to a problem? Please describe.

Currently when caching an enpoint response with @UseCache, the cache-control header is set with the ttl of that cache.

The problem we are facing is that our server side caching is different from the client side caching:
We have an endpoint that returns data based on the accept-language header, which represent the language our app is in. On the server, we cache the response, based on the accept-language header. The problem here is that any http client by default the cache-control header will take precedence over the accept-language , leading to an issue that the response will stay in the previous language even if the apps switched language.

To be able to resolve this issue we ask for the possibility to have more control over this cache-control header when configuring the cache 🙏🏽

Describe the solution you'd like

A new configuration like this:

@Configuration({
    cache: {
        disableCacheControl: true;
    } 
})

and then change it in the cache interceptor:

if (!this.disableCacheControl) {
   const calculatedTTL = this.cache.calculateTTL(result, ttl);

   $ctx.response.setHeaders({
     "cache-control": `max-age=${calculatedTTL}`
   });
}

Describe alternatives you've considered

No response

Additional context

No response

Acceptance criteria

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants