Why is PATCH neither safe nor idempotent?

I am having trouble understanding why PATCH is not safe where PUT is. Aso idempotent part - if I update the resource field, will this field not return the same value after the update?

+4
source share
2 answers

First of all, it is PUTalso unsafe.

Safe methods are HTTP methods that do not modify resources. For example, using GET or HEAD on a resource URL, NEVER change the resource.

Since the request PUT(like PATCH) updates the resource, it cannot be cached and therefore not SAFE.

PUT , , PUT .

HTTP- - HTTP, . , . . , , . (, , ().

PUT, idempotent, , , , - . PUT GET , . : - - PUT

PATCH , . , PATCH . , IDEMPOTENT.

: - Person

1: PATCH/person/1 {'age': 10} - 10

, ,

2: PATCH/person/1 {'age': 19} - 19

, 1, 10, .

, etags If Modified Since headers.

0

PATCH . , NON .

From Name=John to Name=Gargantua. 

Gargantua, , ""

"from Name=John"

0

Source: https://habr.com/ru/post/1665286/


All Articles