Just turning it on with gzip_static on didn't work for me. I had to use the gzip_proxied before it started working.
location /as/ {
gzip_static on;
gzip_proxied expired no-cache no-store private auth;
gzip_min_length 500; # optional
gzip_types text/plain application/xml text/css; # optional
add_header Z_LOCATION "gz static location block"; add_header URI $uri; # DEBUG info
}
Note the last line adds another two headers that help debugging. You can see these using a great plugin for Firefox called "Live HTTP Headers", which I found super useful for debugging a load of things around headers and caching. Note that "curl -I" doesn't work as it doesn't send a header saying it accepts gzip encoding.
You should also make sure the files have the same modification date
touch style.css style.css.gz
Here are the headers I get back when I use the location config above
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 06 Jan 2016 20:07:18 GMT
Content-Type: text/css
Last-Modified: Wed, 06 Jan 2016 19:55:15 GMT
Etag: "568d7123-84c"
Z_LOCATION: gz static location block
URI: /as/style.css
Via: 1.1 BC5-ACLD
Connection: Keep-Alive
Content-Encoding: gzip
Age: 0