Illustrating HTTP Chapter 5: A web server working with http

5.2 Communication data forwarders: proxies, gateways, tunnels

  • In http communication, in addition to the client and server, there are some applications for communication data forwarding , such as proxy, gateway and tunnel,

    1. Proxy: It is an application with forwarding function, which plays the role of the middleman between the server and the client, accepts the request sent by the client and forwards it to the server, and also accepts the response sent by the server and forwards it to the client.

      • The entity server that holds the resource is called the origin server. During the HTTP communication process, multiple proxy servers can be cascaded. The forwarding of requests and responses requires additional Via header fields to mark the passing host information.
        write picture description here
      • Why use a proxy?

        1. Use caching technology to reduce network bandwidth traffic
        2. Site-specific access control within an organization
        3. Main purpose until the date of visit
      • There are many ways to use the proxy, which are classified according to two benchmarks, one is whether to use the cache, and the other is whether the message will be modified.

        1. Proxy caching: When the proxy forwards the response, the caching proxy will save a copy of the resource (cache) on the proxy server in advance. When the proxy receives a request for the same resource again, it can not obtain the resource from the origin server, but instead The previously cached resource is returned as a response.
        2. Transparent proxy: When forwarding a request or response, the proxy type that does not process the message is called a transparent proxy. On the contrary, the proxy that processes the content of the message is called a non-transparent proxy.
    2. Gateway: It is a server that forwards the communication data of other servers , receives the request sent from the client, and processes the request like the original server that owns the resources. Sometimes the client is not aware that the destination of its communication is a gateway.
      • The working mechanism of a gateway is very similar to that of a proxy. The gateway enables the server on the communication line to provide non-http protocol services.
        write picture description here
      • Using the gateway can improve the security of communication, because the communication line between the client and the gateway can be encrypted to ensure the security of the connection. For example, the gateway can connect to the database and use SQL statements to query data. When performing credit card settlement on a shopping site, the gateway can be linked with the credit card settlement system.
    3. Tunnel: An application that relays (using encrypted means such as SSL for communication) between a client and a server that are far apart, and maintains the communication connection between the two parties. The purpose of the tunnel is to ensure secure communication between the client and the server. , it will end when the two communicating parties are disconnected
      write picture description here

5.3 Cache for saving resources

  • What is cache? Refers to a copy of a resource saved on the proxy server or on the client's local disk. Using caching reduces access to origin servers, thus saving traffic and time.
  • A cache server is a type of proxy server. The advantage is that the cache can be used to avoid forwarding resources from the origin server multiple times, the client can obtain resources from the cache server nearby, and the origin server does not have to process the same request multiple times.
    write picture description here

  • The validity period of the cache ,
    even if there is a cache in the cache server, it cannot guarantee that the request for the same resource will be returned every time. Due to the client's request, the validity period of the cache and other factors, the validity of the resource will be confirmed to the origin server again. If the cache is invalid, new resources will be obtained from the origin server again.
    write picture description here

  • The client's cache , the cache not only exists in the cache server, but also exists in the client browser, and the client cache is also called (temporary network file).
  • If the browser cache is valid, there is no need to ask the server for the same resource, and it can be read directly from the local disk. If the browser cache is invalid, the new resource will be requested again.
    write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326382823&siteId=291194637