dodyg / practical-aspnetcore

Practical samples of ASP.NET Core 9 RC1, 8.0, 7.0, 6.0, 5.0, 3.1, 2.2, and 2.1,projects you can use. Readme contains explanations on all projects.
MIT License
9.18k stars 1.18k forks source link

Net6.0 Caching example 4 - counter is not matching the amount of page refreshes #373

Closed djsleurink closed 1 year ago

djsleurink commented 1 year ago

When refreshing the page in the browser 2 requests are made. One for the favicon and one with path "/". Skip the favicon request to have the counter match the amount of refreshes. Also, because it now skips over the 8th refresh, the message "Cache expired" is never displayed.

Multiple ways to fix this, but this would be the simplest one i guess. Another option is to create a middleware that can be reused whenever this problem occurs in other examples.