Output Cache doesn't work when user has Cookie Authentication cookies
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
After a user logs in to my website using Google/Facebook the output cache doesn’t work anymore due to .AspNetCore.Cookies.
Please change the default policy so only for action/controller that has Authorize
on it the output cache will be ignored instead when the user is logged in.
The current behavior is not correct because logged in user views static content that should come from output cache.
Describe the solution you’d like
Change the behavior of the default policy to ignore output only when action/controller has Authorize
attribute.
Additional context
No response
Issue Analytics
- State:
- Created 5 months ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
OutputCache not working when using Reponse.Cookies
In a particular ActionResult I'm writing some data to cookies. The output cache is not working in that action result. Its working fine...
Read more >Output caching middleware in ASP.NET Core
Responses that set cookies aren't cached. Responses to authenticated requests aren't cached. The following code applies all of the default ...
Read more >What are the risks of just clearing cookies instead ...
Discarding your token by deleting your cookies, clearing cache, etc., is simply destroying your copy of the key. Explicitly logging off is ......
Read more >Response caching in ASP.NET Core
With output caching, configuration decides what should be cached independently of HTTP headers. May be beneficial for public GET or HEAD API ...
Read more >Removing cookies in Varnish - Varnish Developer Portal
In the end if a sessionID or cart cookie is set, Varnish will not cache, assuming the origin application needs the values of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@offirpeer As @sebastienros mentioned above, the caching policy can be overridden to modify the behavior (including allowing you to enable caching on authenticated requests).
As a platform we try to choose safe defaults where possible to minimize the chance of accidental misuse, so it’s unlikely that we will change the default behavior here.
By design and documented, when a user is authenticated output caching is disabled for the request.
Custom routes or actions can use a custom policy that will enable caching even for authenticated requests. Documentation is here: https://learn.microsoft.com/en-us/aspnet/core/performance/caching/output?view=aspnetcore-7.0