Comments (5)
Hello @MohamadTahir
Thanks for taking the time to report this issue and the workaround! 👍 🙏
from idempotentapi.
Always welcome @ikyriak
there is another thing, after doing some search I realized that unsuccessful responses should not be cached when implementing idempotency, why? what if a transient error occurred? the user should be able to process the same quest with the same idempotency key, this package behaves correctly when the error occurs before reaching the controller, what do I mean by this?
so let's say that we have a request model like the following
public record SampleModel
{
[MinLength(3)]
public int[] { get; set; } = Array.Empty<int>();
}
if the user sends a request and the array size is 2, then the request won't go inside the controller and will return 400, in this case, the package won't cache the response, which is the correct behavior.
but what if the user sent an array of size 4, there will be no validation errors and the request will go into the controller, in there we do our own validation on the data that has been provided in the array then decide that we need to return the NotAcceptableResult
response for whatever reason, in this case, since the request is returned from within the controller it will be cached by the package, which is not the behavior that we look for.
from idempotentapi.
Hello @MohamadTahir
The issue of the NotAcceptedObjectResult
will be fixed in the following major release, as you have provided a workaround for the moment.
Regarding the "unsuccessful responses should not be cached":
In the 1.0.2-prerelease-01
version, you can set the CacheOnlySuccessResponses
attribute option to true/false
. Currently, the default is false
not to change the current behavior. However, the default value will be true
in the following major release. You can see more details in issue #37.
Is this behavior working for your case?
from idempotentapi.
Perfect, that's what we want, we want to cache only successfully responses
from idempotentapi.
Hello @MohamadTahir,
The fix for the NotAcceptedObjectResul
issue has been released in v2.0.0-RC.01 🎆 🎉 . Could you please verify that it's OK?
from idempotentapi.
Related Issues (20)
- Get 409 status code when retry HOT 5
- Failed to get correct hash value with same request body HOT 2
- IdempotentAPI.DistributedAccessLock.MadelsonDistributedLock not found in NuGet repository HOT 6
- Default name of idempotency header key HOT 2
- Make all code async
- What do you do with Content-Type caching? HOT 2
- Support MinimalAPI projects HOT 1
- Performance Issue when using Distributed Cache in MSSQL DB HOT 1
- Make idempotency optional HOT 9
- Potential idempotency issue HOT 4
- Request data hash always returns empty byte array HOT 2
- Specify the ExpireHour in Timestamp instead of int HOT 4
- Latest nuget breaks on minimal API having HttpResponse in its action HOT 5
- Possibility to configure controllers via IdempotencyOptions HOT 1
- FastEndpoints support? HOT 8
- For Minimal APIs, how to configure the idempotent options for a specific endpoint, not generally? (cache deadline, etc) HOT 2
- Feature: Configurable JSON serializers HOT 6
- 406 Not Accepted on cached response with Content-Type: application/json; charset=utf-8 HOT 5
- Framework 4.8 support HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from idempotentapi.