HTTP notes

Status code

204

  • Status 204 代表的是「請求成功,但沒有 BODY」, 這個比較常用在 DELETE 操作

304 Not Modified

  • There is no need to retransmit the requested resources.

This happens when:

  1. the request method is a safe method, such as GET or HEAD
  2. when the request is conditional and uses an If-None-Match or an If-Modified-Since header.
{
"header": {
"If-None-Match": <e-tag>
}
}

HTTP Header

X-HTTP-Method-Override

For some HTTP clients can only work with simple GET and POST requests. Use X-HTTP-Method-Override with a string value to contain PUT, PATCH, DELETE

X-Total-Count

  • A count of the total number of Pagination count

E-tag

  • The server gives client resources associated with E-tag

Next time, the client sends the same request with given E-tag, the server will use that E-tag to tell if it changes or not

  • header: If-None-Match => if resource is not changed, status 304 not Modified => response quickly

Pros

  • Fast response
  • Less bandwidth
  • Control consistency and concurrency

Cons

  • Two servers behind load balancer may generate two E-tags (But it is configurable!)
  • E-tag can be used to track users (e-tag is harder deleted than cookie)

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eddie Cheng

Eddie Cheng

「0」が過去で「1」が未来「今」は何処にもない