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
TTCLOUD is a relatively new foreign hosting sales...
Most IT organizations are under pressure to be mo...
The promise of 5G has yet to be fulfilled, but it...
Megalayer is restocking VPS with special annual p...
When we set up a wireless router, we need to ente...
[[405467]] In order for your services to take adv...
For data center operators, the idea of a wirele...
Judging from the scene of MWC2018, 5G has become ...
In web development and network applications, impl...
Recently, China Mobile, China Telecom and China U...
"Vigorously develop the digital economy, imp...
Advances in technology are dramatically changing ...
[[398656]] This article is reprinted from the WeC...
On the evening of May 17, World Telecommunication...
The discussion on China Unicom's predicament ...