question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Output Cache doesn't work when user has Cookie Authentication cookies

See original GitHub issue

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.

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:closed
  • Created 5 months ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
adityamandaleekacommented, May 5, 2023

@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.

1reaction
sebastienroscommented, May 2, 2023

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found