2009年5月24日 星期日

High Performance Web Sites memo(2)

HTTP Overview 2

A GET request includes a URL followed by headers.The HTTP response contains a
status code, headers, and a body.
------------------------
Compression

The size of the response is reduced using compression if both the browser and server
support it.Browsers announce their support of compression using the Accept-
Encoding header.Servers identify compressed responses using the Content-Encoding
header.

------------------------
Conditional GET Requests

If the browser has a copy of the component in its cache, but isn’t sure whether it’s
still valid, a conditional GET request is made.If the cached copy is still valid, the
browser uses the copy from its cache, resulting in a smaller response and a faster user
experience.

Typically, the validity of the cached copy is derived from the date it was last modified.
The browser knows when the component was last modified based on the Last-
Modified header in the response

It uses the If-Modified-Since header to send the last modified date back to the server.The
browser is essentially saying, “I have a version of this resource with the following last
modified date. May I just use it?”

If the component has not been modified since the specified date, the server returns a
“304 Not Modified” status code and skips sending the body of the response, resulting
in a smaller and faster response.

In HTTP/1.1 the ETag and If-None-Match headers are another way to make conditional GET requests

--------------------------------
Expires

Conditional GET requests and 304 responses help pages load faster, but they still
require making a roundtrip between the client and server to perform the validity
check

The Expires header eliminates the need to check with the server by making it
clear whether the browser can use its cached copy of a component

----------------------
Keep-Alive

Persistent Connections (also known as Keep-Alive in HTTP/1.0) was introduced to
solve the inefficiency of opening and closing multiple socket connections to the same
server

It lets browsers make multiple requests over a single connection.Browsers
and servers use the Connection header to indicate Keep-Alive support.The
Connection header looks the same in the server’s response.

The browser or server can close the connection by sending a Connection: close
header.Technically, the Connection: keep-alive header is not required in HTTP/1.1,
but most browsers and servers still include it.

Pipelining, defined in HTTP/1.1, allows for sending multiple requests over a single
socket without waiting for a response.Pipelining has better performance than persistent
connections



http://docs.google.com/Present?docid=dfb9f5wn_168fc36vgdr

Why is "primed cache same session" different from "primed cache different session"?

Browsers store resources in memory so they don't need to read them from disk.

---------------
Two considerations with disk cache

* Is the resource fresh (vs. expired)?
* If it's expired, is it valid (vs. updated)?

If a resource is fresh, no HTTP request is made – it's just read from disk.

If a resource is expired, a Conditional GET request is made.

* If the resource is valid, it's read from disk and the Conditional GET response is empty.
* If the resource has been updated, the Conditional GET response contains the updated version.

沒有留言: