A tester pinged me about a paging bug. Page two of a product list showed the same items as page one. Not similar, identical, right down to the order. I opened the endpoint, read the handler twice, and couldn't find anything wrong with it. It took a page number, skipped and took the right rows, returned them. On my machine it worked. In the deployed build it didn't.
The only thing I'd touched that week was adding output caching. That turned out to be the whole story.
What I thought I was doing
ASP.NET Core's output cache keys a response so a repeat request skips the handler. When I first wired it up it was just this:
app . MapGet ( "/products" , ( int page ) => GetProducts ( page )). CacheOutput ();
Enter fullscreen mode
Exit fullscreen mode
And it behaved exactly how I wanted. Page one and page two cached separately. I know because I checked, more on that in a second. The default policy varies the cache key by every query string parameter.…