What does `expires -1` mean in NGINX `location` directive?

Joshua Powell picture Joshua Powell · Jun 18, 2015 · Viewed 13.2k times · Source

Given the sample location example below, what does -1 mean for expires? Does that mean "never expires" or "never caches"?

# cache.appcache, your document html and data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
  expires -1;
  access_log logs/static.log;
}

https://github.com/h5bp/server-configs-nginx/blob/b935688c2b/h5bp/location/expires.conf

Answer

Marki555 picture Marki555 · Jun 18, 2015

According to nginx manual, this directive adds the Expires and Cache-Control HTTP header to the response.

Value -1 means these headers are set as:

Expires: current time minus 1 second

Cache-Control: no-cache

So in summary it instructs the browser not to cache the document.