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
The development of the animation industry is of g...
On December 31 last year, the New York Stock Exch...
Continuing with the year-end summary, many friend...
[[434445]] According to foreign media reports, af...
I believe everyone can feel that using multithrea...
Hello everyone, I am Fisherman. Channel is a uniq...
Sharktech cancelled the lowest-priced $59/month L...
What can 5G do? This is a question that everyone ...
[[272520]] When users apply for number portabilit...
On August 20, 2019, Aruba, a subsidiary of Hewlet...
spinservers is a site under Majestic Hosting Solu...
From the initial standard to its implementation, ...
On July 15, 2016, Huawei's Smart City Ecosyst...
[[375109]] 【51CTO.com Quick Translation】5G techno...
[51CTO.com original article] At 9:00 am on May 22...