Cache attribute changes response status code to 200 regardless of original response code
This line forces cache output to always set response code 200 when responding with cached answer https://github.com/Iamcerba/AspNetCore.CacheOutput/blob/269322c126a8971bf73836863c7a7dffbc6caa41/AspNetCore.CacheOutput/CacheOutputAttribute.cs#L187
Consider following scenario:
- API controller takes parameters and returns NoContent (204) in some cases. It has CacheOutput attribute set on controller method
- frontend fetch js api checks if it is 200 or 204. If response code is 200 then fetch does
await response.json() - next call to controller with same parameters returns empty body with response code 200. Json parse fails
Could you please add feature to respect response statuses? It would be more performance effective for API controllers then responding with empty dummy jsons. Thanks a lot for amazing work!
Yes, taking into account that HTTP 204 is cacheable current behavior looks like not what at least me expected to see.
Will get back to you later, need to think how to handle this. Don't want server side caching to rely on cached content value to determine status code, original status code ideally should be stored as part of the cache. I'm considering merging all "secondary" cache keys (ContentTypeKey, EtagKey, LastModifiedKey + new status code key) and corresponding values to a single cache entry.
https://github.com/Iamcerba/AspNetCore.CacheOutput/compare/master...fix/issue-30
Also released pre release packages in NuGet. Check "3.0.0-pre1" version.
Thanks a lot, that's really amazing! New version works as expected. All test runs are also fine, at least for InMemory model