Reduce allocations in cookie value parsing
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
In the March 5th ASP.NET Community Standup @davidfowl mentioned perf improvements made by the team and the great @benaadams in header handling. I wanted to share that while profiling one of our apps one main contributor to string allocations is the cookie value parsing. Those allocations are just after refreshing the page 3 or 4 times.

Our app has a lot of cookies, anywhere between 30 & 40 cookies. However, most of the cookies (80%) come from third party scripts like:
- Google Analytics: adds 4 cookies
- Adobe SiteCatalyst: adds 4 cookies
- Optimizely: adds 2 cookies
- Dynatrace: adds 4 cookies
The list goes on and on, but you get the idea. Our apps do not care about these cookies, we have no interest in accessing them. Even our own cookies are not access on each request. So the question is, would it be possible to make the cookie value parsing even more lazy and only parse the cookies we explicitly ask for (`Request.Cookies["SomeCookie"]`)?
This is a very common problem. Here are a few popular websites with the issue of third party scripts polluting the domain with cookies:
https://www.cnet.com:

https://www.cnn.com

https://www.espn.com

Contributor guide
Assessment
This issue has not been assessed yet.