HTTP

Client / Server interaction

GET / HTTP/1.1
Host: xkcd.com
Accept: text/html
User-Agent: Mozilla/5.0 (Macintosh)
HTTP/1.1 200 OK
Date: Sat, 02 Apr 2011 21:05:05 GMT
Server: lighttpd/1.4.19
Content-Type: text/html

<html>
  <!-- ... HTML for the xkcd comic -->
</html>

EXAMPLE

HTTP Methodes supported

  • POST
  • PUT
  • GET
  • DELETE
  • Modern browsers support
  • REST (Representational State)

HTTP Methodes All

  • OPTIONS
  • GET
  • HEAD
  • POST
  • PUT
  • DELETE
  • TRACE
  • CONNECT
  • PATCH ***

HTTP Status Codes

  • 200
  • 304
  • 404
  • 500
  • ...

Symfony2 Response constants

  • Successful 2xx 
  • Redirection 3xxx
  • Client error 4xx
  • Server error 5xx

EXAMPLE

HTTP Headers

Most important  browser headers for end-user: performance:

  • HTTP version (HTTP/1.0 or HTTP/1.1)
  • Accept-Encoding: gzip, deflate
  • Connection: Keep-Alive
  • If-* headers
  • Cache-Control or Pragma no-cache

HTTP Headers

 

  • HTTP version (HTTP/1.0 or HTTP/1.1)
  • Accept-Encoding: gzip, deflate
  • Connection: Keep-Alive

HTTP 1.0 does not include compression.

gzip & deflate compress the website

Connection: Keep-Alive will reuse TCP connections for subsequent requests and will save on the latency 

 

HTTP Headers

  • If-* headers
  •  If-Modified-Since, will enable the web server to send a response that indicates the content has not been modified if this is true.
  • if-None-Match
  • if-Range
  • if-Unmodified-Since

 

 

HTTP Headers

  • Cache Control or Pragma no cache
  • cache-control: private, max-age=0, no-cache
  • private -- content is specific to end user
  • max-age -- when asset is expired. It is in seconds.
  • no cache -- cache should revalidate this resource each tim
  • pragma: no-cache == cache-control: no-cache

 

 

HTTP Headers

Most important  server headers for end-user: performance:

  • The HTTP version (either HTTP/1.0 or HTTP/1.1) at the beginning of the status line
  • Connection: Keep-Alive/Close
  • Encoding: gzip, deflate
  • The various cache-control headers, especially max-age
  • Content-Type:
  • Date:
  • Accept-Ranges: bytes

HTTP Headers

Most important  server headers for end-user: performance:

  • The HTTP version (either HTTP/1.0 or HTTP/1.1) at the beginning of the status line
  • Connection: Keep-Alive/Close
  • Encoding: gzip, deflate
  • The various cache-control headers, especially max-age
  • Content-Type:
  • Date:
  • Accept-Ranges: bytes

HTTP Headers

Most important  server headers for end-user: performance:

  • The HTTP version (either HTTP/1.0 or HTTP/1.1) at the beginning of the status line
  • Connection: Keep-Alive/Close
  • Encoding: gzip, deflate
  • The various cache-control headers, especially max-age
  • Content-Type:
  • Date:
  • Accept-Ranges: bytes

HTTP Headers

  • Content-type is important for telling the browser how to handle the object. This is most important for content that the browser hands off to plug-ins (Flash, Microsoft Office documents, etc.).
  • The Accept-Ranges header is only important when downloading PDF documents. It enables the browser to know that it can request the PDF document one page at a time.

EXAMPLE

HTTP

By Kruno Knego

HTTP

In-house education at Locastic.

  • 730
Loading comments...

More from Kruno Knego