background: A new colleague asked me that there were many options requests in my project, and the background services were down, and I didn’t know how to deal with it;
http protocol In fact, the most commonly used HTTP methods are: GET, POST; they can be used as data exchange between the front-end and the back-end; Under what circumstances do options appear
When the above three situations occur, options requests will appear. To put it simply, it is for server security. For example, the same-origin policy triggers this rule; Options are usually initiated automatically by the browser, and their purpose is to check whether the next method (GET, POST, PUT, delete) is supported by the server; How to deal with the server Check the following A: Method
If your project is considered safe, just return a 200 status code. B: Method
If your project is considered safe, just return a 200 status code. If not allowed you can put back status code 400 or something; Options requests affect service performance, how to optimize Originally, one request was enough to complete the task, but the frequent addition of many options inevitably caused pressure on the service; It is possible to cache options requests. For example, options requests will appear in the http://www.**.com/api/getUser interface. We cache options once when options are returned, and inform the front-end not to send options when requesting this interface in the future. When the server responds, the Access-Control-Max-Age time can be set, which is 10 minutes by default. Further understanding of options Functions of key fields related to options
MDN's description of OPTIONS The HTTP OPTIONS method is used to obtain the communication options supported by the target resource. The client can use the OPTIONS method for a specific URL or for the entire site (by setting the URL to "*"). |
<<: Four departments jointly issued a document, and 5G development has attracted attention again
>>: Network charges are more affordable and 5G demand is gradually released
What is DNS? Each IP address can have a host name...
The basic process of network construction include...
The majority of the world’s population – 95% – is...
The topic we are going to talk about today is abo...
Since last year, IPTV has enjoyed a resurgence. T...
spinservers has released a special promotional US...
[[382120]] This article is reprinted from the WeC...
The tribe has always been mainly sharing low-pric...
[[353891]] Today, the number of IoT devices is gr...
December 12 morning news (Jiang Junmu) The global...
PacificRack is a domain name under QN Data Center...
This year, "new infrastructure" has bec...
[[431894]] With the continuous advancement of 3GP...
1. Introduction In-band SDN networks have attract...
On October 26, foreign media reported that accord...