Closed flc closed 6 years ago
Mostly the OPTIONS
request was send by browser rather than axios instance, when you make a CORS request. So we can't/shouldn't handle the OPTIONS
request.
Hi, thank you for the prompt response! I use django rest framework on the backend that returns useful metadata of resources to an OPTIONS request. For example to dynamically build forms on the client side. http://www.django-rest-framework.org/api-guide/metadata/ What do you think?
9.2 OPTIONS The OPTIONS method represents a request for information about the communication options available on the request/response chain identified by the Request-URI. This method allows the client to determine the options and/or requirements associated with a resource, or the capabilities of a server, without implying a resource action or initiating a resource retrieval. Responses to this method are not cacheable.
With the w3 spec definition, only GET
and HEAD
response could be cacheable, so we may should not cache the OPTIONS
response imo. Check the spec: https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
Thanks for your feedback!🙂
i guess it's plan B then :) what the drf metadata docs suggest under section "Creating schema endpoints". thx for your responses, i'm closing this.
Hi, I would like to cache OPTIONS calls along with GET requests. Is it possible? If I understand correctly, currently the cache is only enabled
if method === 'get'
. However I think it's a common use case to cache OPTIONS requests as well.