Hi All,

I am currently working on $subject for APIM REST APIs in C5.

Why is it important to have this:

   - In APIM 3.0.0, we are including features such as ballerina editor etc
   which gives the capability to users to edit APIs. For editing ballerina
   file etc, one user might take some amount of time before saving his work
   and that amount of time will be greater than earlier in C4 based APIM
   versions. So there is a possibility that he may overwrite other's work when
   multiple people are editing at the same time.
   - In APIM 3.0.0, we are doing almost all implementation of Publisher,
   Store and Admin apps as client side apps. So client-side caching may play a
   good role in improving the apps' performance.


In previous APIM 2.1.0, we did a similar feature for Store REST API for
using ETag and If-Non-Match headers [1].


ETag based client-side caching:

   - A user request for a resource: GET /apis/1234-5678-1234-5678
   - Server responds with the resource with a fingerprint of the current
   state of the resource in a header, which we call ETag header

HTTP/1.1 200 OK
Content-Type: application/json
ETag: "9876-9876-9876-9876"


   - The user sends GET a request to the same resource, but with the ETag
   value he got with the If-Non-Match header

GET /apis/1234-5678-1234-5678
If-Non-Match: "9876-9876-9876-9876"


   - The server checks the ETag sent by the client matches with the current
   state of the resource.
   - If it matches, Server responds with 304 Not Modified response.
      - Otherwise, the server responds with the full response payload along
      with the new ETag header.


Concurrency controlling when someone is updating/deleting a resource:


   - A user updates a resource with a payload. He also sends the ETag value
   he already has for the resource as If-Match header.

PUT /apis/1234-5678-1234-5678
If-Match: "9876-9876-9876-9876"

[payload - data]


   - The server compares the If-Match header with the currently evaluated
   fingerprint of the resource.
   - If they match, the operation is allowed.
      - If not match, the operation is forbidden and the server responds
      with 412 Precondition Failed.


A good article on caching can be found in [2].

Please let me know your thoughts.

Thanks!
Malintha

[1] [Architecture] Concurrency controlling for API Manager
[2] https://developers.google.com/web/fundamentals/performan
ce/optimizing-content-efficiency/http-caching
-- 
Malintha Amarasinghe
Software Engineer
*WSO2, Inc. - lean | enterprise | middleware*
http://wso2.com/

Mobile : +94 712383306 <+94%2071%20238%203306>
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to