1

We are creating a rest api in our asp.net core project.

For managing the cache we use the response cache middleware and the responseccache attribute that adds these headers to the response :

Cache-Control: public,max-age=2592000

Now what I would like to do is to handle the "ETag" header or "Last Modified" and "If modified since" headers.

Is there any package available for simplifying the implementation of these headers ?

Here I want to manage cache to just the headers, there is a lot of solution for generating Etag but it's still executing server side code.

remi bourgarel
  • 9,231
  • 4
  • 40
  • 73
  • Possible duplicate of [Implement HTTP Cache (ETag) in ASP.NET Core Web API](http://stackoverflow.com/questions/35458737/implement-http-cache-etag-in-asp-net-core-web-api) – Stout01 May 11 '17 at 16:27
  • @Stout01 this post only handles the creation of Etag, not the caching part (the action is already executed because the code is on the OnActionExecuted) so basicly it's only saving bandwidth not server processing time – remi bourgarel May 12 '17 at 14:07
  • @remi bourgarel Are you wondering if there's any package for handling caching of HTTP responses including the logic involving ETag and Last Modified (on the consumer side of things) or how to generate ETags and add them to the response from your API? – Joakim Skoog Jun 13 '17 at 13:11
  • @JoakimSkoog for a package that would help me to generate etag, then compare them when the client asks for comparison (304 response) and generate the appropriate headers for a HEAD request without getting the whole data – remi bourgarel Jun 15 '17 at 13:38
  • @remibourgarel appreciate this is a bit late, and you might have already found it. But in case not, look at: https://learn.microsoft.com/en-us/aspnet/core/performance/caching/response and https://learn.microsoft.com/en-us/aspnet/core/performance/caching/middleware. This handles the headers and caching, not sure about the actual 304 response. Will try to look at it a bit more in depth and post a solution if I come up with something adequate. – erikbozic Jul 10 '17 at 08:13

0 Answers0