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

.NET 7.0: Output Caching: Evaluate policy after other middleware processed the request #44191

Open
1 task done
Belphemur opened this issue Sep 26, 2022 · 2 comments
Open
1 task done
Assignees
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Milestone

Comments

@Belphemur
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

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

When providing APIs to be used publicly, some error code like 404 might worth to be cache longer than success code since we know this state won't change anytime soon.

In my case, I provide an API to search for subtitle for shows.

The api take the searched show from the URL. It's more than possible that said show isn't available on my service yet.
I return a 404 and like to cache that result for longer than a succesful found show with subtitles.

Describe the solution you'd like

Delay evaluation of policy to when we have a response to let the developer use HttpContext.Response as part of rule for matching policy, like its status code.

Additional context

Currently we have access to the response using the .With(context => context.HttpContext.Response.StatusCode == 404); when defining a policy. The issue is, since the response isn't created yet, the status code is always 200.

Since there isn't yet a full documentation of the capabilities of the With method, it can leads to unexpected cases.

@ghost
Copy link

ghost commented Sep 28, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@Belphemur
Copy link
Author

I understand on that case, the doc should specify that the response can't be used to make output cache policies.

@amcasey amcasey added area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
@amcasey amcasey modified the milestones: .NET 8 Planning, Backlog Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlesware area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

No branches or pull requests

5 participants