Refining front-end knowledge points: June

Time:2022-1-4

1.Koa

Response alias
  • The following accessors are equivalent to the response alias:

    • ctx.body
      ctx.body=
      ctx.status
      ctx.status=
      ctx.message
      ctx.message=
      ctx.length=
      ctx.length
      ctx.type=
      ctx.type
      ctx.headerSent
      ctx.redirect()
      ctx.attachment()
      ctx.set()
      ctx.append()
      ctx.remove()
      ctx.lastModified=
      ctx.etag=

3. Quick knowledge of tour guide

Force refresh viewer overloaded resources
  • Manually clear browser cache data once
  • In devtools, select disable cache in performance
  • Forced refresh shortcut [Command + Shift + R]

3. HTTP review notes

Layers under TCP / IP protocol family (including HTTP, FTP, TCP, DNS, ICMP, PPPoE, etc. are only subsets):
  • HTTP is located in the application layer, which determines the communication activities when providing application services to users. Application services such as FTP and DNS (domain name system) are located in this layer
  • There are two protocols in the transport layer: TCP and UDP. TCP protocol adopts the three-time handshake strategy. (Note: Socks5 is a network proxy protocol based on transport layer. In the fifth version of socks, it can forward any application layer communication activity based on TCP / IP protocol. However, the reason why we can’t cross the wall at the terminal is that it doesn’t support sock5 proxy protocol and HTTP proxy, so we can’t realize communication activity. The usual solution is to configure a full proxy for the terminal program by using environment variables (Agency)
  • The network layer, that is, the IP protocol layer, is used to process the data packets flowing on the network, add the MAC address of the communication destination and forward it to the link layer. To transmit various data packets to each other, various conditions need to be met to ensure the accuracy of transmission, among which the most important conditions are IP address and MAC address.
  • The link layer is used to handle the hardware part of the connected network. Including: control operating system, hardware device driver, NIC network card, optical fiber, etc.
IP address, MAC address
  • IP address: the address to which the node is assigned
  • MAC address: the fixed address of the network card
  • IP address can be paired with MAC address.
  • ARP is a protocol that can resolve the address. According to the IP address of the communication party, the corresponding MAC address can be found out. (however, no one can fully grasp the real transmission status. When sending a packet to an IP address, ARP analysis will only analyze about one MAC address router, and then send it to the next MAC router. In the middle, it needs to be transferred to several MAC routers to reach the receiving end. This is the routing mechanism.)
Uri uniform resource identifier
  • Refining front-end knowledge points: June
  • That is, the content of front and back end routing. For example, the URL module extension integrated in node. In the front-end framework vueroter, the hash and history modes are # used, and the browser window is used. There is a history object to save the browsing history.
Agent, gateway, tunnel

HTTP communication. In addition to the client and server. There are also applications for communication data forwarding, such as agents, gateways, tunnels. They can work with the server

  • Agent:Accept the request sent by the client and forward it to the server, and also accept the response returned by the server and forward it to the client

    • Cache agent:Cache server is a kind of proxy server, which is merged in this category. The advantage of cache server is that using cache can avoid forwarding resources from the source server many times. (for example, the basic principle of CDN content distribution network is to adopt various cache servers. The full name of CDN is content delivery network, that is, content distribution network. Its purpose is to publish the content of the website to the network “edge” closest to users by adding a new network architecture to the existing Internet , so that users can get the required content nearby, solve the Internet network congestion, and improve the response speed of users accessing the website. Technically, it comprehensively solves the reasons for small network bandwidth, large number of users’ visits and uneven distribution of outlets, and solves the root cause of slow response speed of users accessing the website.)
    • Transparent proxy:When forwarding a request or response, the agent type that does not process the message is called transparent agent. On the contrary, the agent that processes the message content is called non transparent agent.
  • Gateway:Gateway is a server that forwards the communication data of other servers. When receiving the request sent from the client, it processes the request just like the source server with its own resources. Sometimes clients do not realize that their communication target is a gateway.

    • Using the network, the HTTP request can be transformed into other protocol communication. The gateway can enable the server on the communication line to provide non HTTP protocol services, and use the gateway to improve the communication security. For example, the gateway can connect to the database and make SQL statements query data.
  • Tunnel: it is an application that transfers between clients and servers far away and maintains the communication connection between them.

    • Through tunnel transmission, it can communicate safely with long-distance servers. The tunnel itself is transparent, and the client does not care about the existence of the tunnel.
HTTP header field
  • Common header fields:

    • Refining front-end knowledge points: June
  • Request header field:

    • Refining front-end knowledge points: June
  • Response header field:

    • Refining front-end knowledge points: June
  • Entity header field:

    • Refining front-end knowledge points: June

Recommended Today

PostgreSQL example of calculating distance (unit: directly generated meter)

St was used before_ Distance function, but it seems that a unit conversion is required, and it is said on the Internet that the conversion is not particularly accurate. Now temporarily record the algorithm here: select st_distance(ST_GeomFromText(‘POINT(120.451737 36.520975)’,900913),ST_GeomFromText(‘POINT(120.455636 36.520885)’,900913))*60*1.852; The calculation method here can change the coordinate system, but the two coordinate systems have not […]