Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP REST API with ETAG support?

Tags:

rest

php

etag

api

Is there a possibility to create a REST API in PHP that supports ETags?

And if yes, how could you use parse the response in PHP to consider the ETags?

like image 363
Sebastian Hoitz Avatar asked Nov 05 '22 01:11

Sebastian Hoitz


1 Answers

You can find the corresponding request headers in $_SERVER If-Match. Is the key HTTP_IF_MATCH, If-None-Match corresponds to HTTP_IF_NONE_MATCH.

In order to send proper ETags to the client use the ETag header like header( 'ETag: ' . generateEtag() );. You just need to ensure that your ETag represents the response of the service properly.

like image 191
tobyS Avatar answered Nov 09 '22 13:11

tobyS