Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有可能在 PHP 中创建支持 ETags 的 REST API?
如果是,您如何使用解析 PHP 中的响应来考虑 ETags?
您可以在 中找到相应的请求标头$_SERVER If-Match。是关键HTTP_IF_MATCH,If-None-Match对应HTTP_IF_NONE_MATCH。
$_SERVER
If-Match
HTTP_IF_MATCH
If-None-Match
HTTP_IF_NONE_MATCH
为了向客户端发送正确的 ETag,请ETag使用header( 'ETag: ' . generateEtag() );. 您只需要确保您的 ETag 正确代表服务的响应。
ETag
header( 'ETag: ' . generateEtag() );