HTTP 200 Ok

Reference on the HTTP 200 ok response message.

849 views

Edited: 2019-11-23 05:48

The 200 Ok status message is sent by a server to indicate that it was able to process and respond to a HTTP request it has received.

200 ok is typically accompanied by a response body containing either HTML, XML or plain text. But, it can also be followed by an image or a video.

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8

200 Ok and caching

By default, a server will respond with a 200 ok code if the HTTP request was processed successfully. But, it may also respond with a 304 Not Modified code, indicating that the resource should instead be loaded from the browsers cache.

If you want to leverage caching in dynamic web applications, such as content delivered with PHP, you will need implement some sort of caching mechanism. One way to do this is to store "articles" in the database together with a timestamp and then use the IF-MODIFIED-SINCE header.

See also: 304 Not Modified

In PHP you usually do not need to send a 200 Ok response, since it is the default response when none is given.

To find out how to send HTTP response codes in PHP see: PHP: Header

Tell us what you think:

  1. An in-dept look at the use of headings (h1-h6) and sections in HTML pages.
  2. Pagination can be a confusing thing to get right both practically and programmatically. I have put a lot of thought into this subject, and here I am giving you a few of the ideas I have been working with.
  3. The best way to deal with a trailing question mark is probably just to make it a bad request, because it is a very odd thing to find in a request URL.
  4. How to optimize image-loading and automatically include width and height attributes on img elements with PHP.
  5. HTTP headers are not case-sensitive, so we are free to convert them to all-lowercase in our applications.

More in: Web development