Proxy_cache_methods and OPTIONS

Maxim Dounin mdounin at
Fri Sep 19 07:41:07 UTC 2014


On Thu, Sep 18, 2014 at 08:45:32PM -0400, idabic wrote:

> I have bounced around quite a lot through forums and documentation to
> demistique whether the OPTIONS request method is honoured/allowed by nginx
> when it's configured as reverse proxy cache system or not.
> I used a test box with nginx 1.4.6 with 
> "proxy_cache_methods GET OPTIONS;" 
> to test certain use case for a client but, reloading nginx returned obvious
> exception that:
> "invalid value "OPTIONS" in /etc/nginx/sites-enabled/default:35"
> Documentation says:
> =============================================
> Syntax: 	proxy_cache_methods GET | HEAD | POST ...;
> Default: 	
> proxy_cache_methods GET HEAD;
> Context: 	http, server, location
> =============================================
> but I dont' see 1. full list and 2. list of allowed methods when proxy_cache
> is configured - if it makes the difference.

The syntax provided means that only GET, HEAD, or POST method can 
be specified, and there may be more than one method.

As you can see, as of now OPTIONS can't be specified in 
proxy_cache_methods, and responses to OPTIONS requests will not be 
cached.  This is in line with what RFC 2616 says about OPTIONS,

   Responses to this method are not cacheable.

As well as recent RFC 7231,

   Responses to the OPTIONS method are not cacheable.

On the other hand, it should be easy enough to modify the code 
allow caching of OPTIONS requests.

Maxim Dounin

More information about the nginx mailing list