7 Output Caching - Cache by route, with other routes evicting the cache

Alex Winfield 1 Reputation point

I've watched this video:
...and I've looked through the middleware sample project:
...and I still have some questions I'm hoping to get some help with.

If I have an endpoint such as GET /widget/{id}, I don't need any special config options in order for each widget to be cached separately.
But what I don't see, is a way for a POST /widget/{id} to invalidate the cache for just the widget that's updated. I can use tags and invalidate all caches for all widgets, but is there a way to invalidate only the cached item that actually changed?

A set of technologies in the .NET Framework for building web applications and XML web services.
4,284 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce ( 59,051 Reputation points

    typically you don't cache posts. the post body is not part of routing, so it can not be used to effect the cache. caching is controlled by the url and headers.

    a more typical solution is the post/redirect/get. in your case you would tag by widget id, and the post would invalidate the widget tag and redirect to the get. this would also cause the subisquent gets to use get built from the new post data.