- idempotence
HTTP/1.1The definition of idempotent is that one or more requests for a resource should have the same result for the resource itself (except for network timeouts). That is, any number of executions will have the same impact on the resource itself as one execution. Idempotent is not just one (or more) request that has no side effects on the resource (such as a query database operation that has no add, delete, and therefore no impact on the database). Idempotent also means that the first request has side effects on the resource, but subsequent requests do not have side effects on the resource. Idempotent focuses on the side effects of subsequent multiple requests on the resource, not the outcome. Network timeouts are not idempotent.Copy the code
- What are the common HTTP methods? What’s the difference between get and Post?
Security: Request methods do not affect resources on the server idempotent: Perform the same operation multiple times with the same result display declaration Cache: Response headers contain Expires cache-control :max-age, etc. Time Cache get: Request resource request with no body, response with body, support form, security, idempotent and cacheable HEAD: request resource header, request with no body, response with no body, support form, security, idempotent, cacheable post: Send data, body type specified by Content-Type, request with body, response with body, form support, insecure, not idempotent, display declaration cache PUT: Send payload creates or replaces target resource, request with body, response with no body, not supported form, insecure, idempotent, not cacheabledeleteConnect: Create a point-to-point communication tunnel, request without body, response with body, not support form, not secure, not idempotent, not cacheable Detection server supported methods do not support forms, security idempotent, and cannot be cached trace: message loopback test, mostly used for route detection patch: partial modification of resourcesCopy the code
- What are common HTTP request headers and response headers
accept
accept-encoding
accept-language
cache-control
cookie
connection
host
vary
user-agent
upgrade-insecure-requests
if-none-match
if-modified-since
if-match Response header: etag Expires date content-typeCopy the code
- HTTPS is based on the secure sockets Layer (SSL) protocol. It provides transmission encryption and identity authentication to ensure transmission security and uses certificates to verify the authenticity of websites
Both HTTP2.0 and HTTP3.0 are only used for https:// urls
HTTPS three-way handshake:1.client hello
2.server hello
3.certificate
4.server hello done
5.client key exchange
6.change cipher spec
7.finished
8.change cipher spec
9.Finished Specifies the default HTTPS port number443Transmission is encrypted and not easy to hijack. Ca authentication is the SSL certificateCopy the code
- ajax
Ajax is asynchronous JS and XML. It's not a new technology, it's just an old technology. Js uses new methods (referencing xmlHttprequest objects) to synchronize requests: Refers to when a browser requests after only when the server response after come back, to see the response as a result, the process browser can't do other things, can only wait for response from the server refers to when a browser requests an asynchronous request, waiting for the response from the server, during which the browser is not blocked You can go to do other things until the end of the response from the server, Tell you to come back. So we see a synchronous request is the browser page refresh again And asynchronous request local refresh, he won't whole page refresh nature asynchronous requests by the browser to open a new thread to send the request to the server, and why, why is the main thread of the unaffected until the asynchronous thread returned from the server response, And then the main thread is going to handle the response that comes back, the Ajax object, the XMLHttprequest object, which is designed to send asynchronous requests, but also synchronous requests. Code writing steps:1.Create an XMLHttprequest objectvar xmlhttp;
function ajax_demo(){
if(window.XMLHttpRequest){
xmlhttp=new XMLHttpRequest();
}else{
xmlhtt =new ActiveXObject('Microsoft.XMLHttp'); }}2.Register callback function, must inform me te XMLHTTP. The onreadystatechange =function(){
/ /..
if(xmlhttp.redaState==4) {if(xmlhttp.status==400) {}}}3.Establish a connection to the server. This is a short connection xmlhttp.open('POST|GET'.'target url'.true);
trueAccording to the asynchronousfalseSaid synchronization4.Send a request xmlhttp.send(); If you want to pass data to the server, pass it as a parameter1.ReadyState attribute0The request is not initialized1The server connection has been established2Request received3Request in process4Request completed, response ready The status property is the status code of the response 1xx 2XX 3XX 4XX 5XX Server errorCopy the code