Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

This article also participated in the “Digitalstar Project” to win a creative gift package and creative incentive money

preface

In this article you will gain

๐Ÿ‘‰ a picture to understand the difference between HTTP and HTTPS

๐Ÿ‘‰ About HTTP caching process diagram (recommended)

๐Ÿ‘‰ Some common HTTP request headers and response headers explain

๐Ÿ‘‰ Common HTTP status codes and explanations

๐Ÿ‘‰ Protocols and explanations for the use of live video broadcasting

๐Ÿ‘‰ Various parameters and explanations of cookies

๐Ÿ‘‰ This HTTP memo will be updated continuously at……

The difference between HTTP and HTTPS

HTTPS has one more layer of encryption than HTTP

HTTP cache

HTTP cache processing flow

Strong cache

Expires: Indicates an Expires

The values of cache-control are

  • Max-age: the unit is second. The cache time is calculated in seconds from the time when the cache is initiated. If the interval exceeds the number of seconds, the cache is invalid
  • No-cache: no strong cache is used. Check whether the cache is fresh with the server
  • No-store: Disables the use of caches (including negotiated caches) to request the latest resources from the server each time
  • Must -revalidate: This parameter is valid before the cache expires, after which it must be verified with the server

Negotiate the cache

ETag/ LF-none-match, : hash code, which represents the identifier of a resource

Last-modified/lf-modified-since: indicates the time when the file was Last Modified

Common HTTP status code

200: OK, the client request is successful

301: Resources (web pages, etc.) are permanently transferred to another URL

302: Temporary jump

401: Unauthorized – The request is not authorized

404: Requested resource does not exist, possibly the wrong URL was entered

500: An unexpected error occurred inside the server

504: Gateway Timeout- The Gateway or proxy server cannot get the desired response within the specified time.

Request Headers

Accept: The received Type, indicating the MIME Type supported by the browser (content-type returned by the benchmarking server)

Content-type: indicates the Type of entity Content sent by the client

Cache-control: Specifies the caching mechanism followed by requests and responses, such as no-cache

If-modified-since: last-modified on the server to see If the file has changed, accurate to less than 1s

Expires: Cache-controlled. No request is made for this time

Max-age: indicates the number of seconds for resources to be cached locally. Within the validity period, no request is made but the cache is used

If-none-match: ETag of the server to Match whether the file content has changed (very accurate)

Cookie: Cookies exist and are automatically carried when the domain is accessed

Referer: Source URL of the page (applies to all types of requests, will be accurate to the detailed page address, CSRF interception commonly used for this field)

Origin: Where does the original request originate from (only down to port)), is Origin more respectful of privacy than Referer

User-agent: information about the User client, such as the UA header

HTTP Response Headers

Content-type: Specifies the Type of entity Content returned by the server

Cache-control: Specifies the caching mechanism followed by requests and responses, such as no-cache

Last-modified:

The last modification time of the requested resource

Expires: When should a document be considered expired so that it is no longer cached

Max-age: specifies the number of seconds that the client should Cache local resources. This parameter is valid only after cache-control is enabled

ETag: Identifiers for a specific version of a resource. Etags are like fingerprints

Set-cookie: Sets the Cookie associated with the page. The server passes the Cookie to the client through this header

Server: Information about a Server

Access-control-allow-origin: specifies the Origin header allowed by the server (e.g. *).

HTTP request methods

The GET:

Requests a representation of the specified resource. Requests using GET should only be used to GET data

POST:

Used to commit entities to a specified resource, often resulting in state changes or side effects on the server

PUT:

Replace all current representations of the target resource with the request payload

DELETE:

Deletes the specified resource

The HEAD:

Request a response that is identical to the response of the GET request, but without the response body

CONNECT:

Establishes a tunnel to the server identified by the target resource.

The OPTIONS:

Communication options used to describe the target resource.

TRACE:

Perform a message loopback test along the path to the target resource.

PATCH:

Used to apply partial modifications to a resource.

Live video protocol

agreement describe advantages
HLS HTTP Live Streaming, Apple

2. Based on HTTP protocol

3. Divide a video stream into small HTTP-based files for download
cross-platform
RTMP Real Time Messaging Protocol

2. Adobe

3. Based on TCP
Low latency
HTTP – FLV 1. Based on HTTP

2. HTTP + FLV: Encapsulate audio and video data into FLV format and then transmit it to the client through HTTP protocol
Low latency

Cookie

Set-Cookie – response

Name=value The names and values of the various cookies
Expires=Date Cookie validity period. By default, cookies are valid only before the browser is closed.
Path= Path The file directory that limits the range to which the specified Cookie can be sent. Default is current
Domain=domain The default domain name is the domain name of the service that created the cookie
secure Cookies can be sent only during HTTPS secure connections
HttpOnly JavaScript scripts cannot get cookies
SameSite=[None/Strict/Lax] – None Indicates that both same-site and cross-site requests can be sent

Strict Indicates that it is sent only in the same station

– Allows to be sent with top-level navigation and will be sent with GET requests initiated by third party websites

๐ŸŽจ [thumbs up] [concerns] don’t get lost, more front-end dry goods waiting for you to unlock

Phase to recommend

๐Ÿ‘‰ the most complete CSS shadow summary

๐Ÿ‘‰ Thoroughly understand the BFC in the CSS

๐Ÿ‘‰ Best practices for clean JavaScript coding