According to some references below, I assume nginx would downgrade strong etags to weak ones when it modifies response content (e.g. gzip compression). But nginx removes strong etags on gzip compression instead of a downgrade.
- http://nginx.org/en/CHANGES (See "Changes with nginx 1.7.3 08 Jul 2014")
-
*) Feature: weak entity tags are now preserved on response modifications, and strong ones are changed to weak.
-
- https://github.com/nginx/nginx/commit/def16742a1ec22ece8279185eb2b798eb5ffa031
-
Entity tags: downgrade strong etags to weak ones as needed.
-
git clone https://gist.github.com/86f2d5b464f5e88821133c43a9cf4956.git
cd 86f2d5b464f5e88821133c43a9cf4956
docker-compose up -d
curl http://localhost:80/strong_etag -i -H "Accept-Encoding: gzip"
docker-compose up -d
runs 2 nginx servers.
- proxy
- It just does gzip compression of response. See
proxy-nginx.conf
.
- It just does gzip compression of response. See
- upstream
- It just returns a JSON response with an etag.
/weak_etag
returns a weak etag,/strong_etag
returns a strong one. Seeupstream-nginx.conf
.
- It just returns a JSON response with an etag.
- Etag header exists.
- nginx downgrades the strong Etag to weak Etag as described at https://github.com/nginx/nginx/commit/def16742a1ec22ece8279185eb2b798eb5ffa031.
HTTP/1.1 200 OK
Server: nginx/1.17.6
Date: Wed, 01 Jan 2020 11:34:44 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Etag: d41d8cd98f00b204e9800998ecf8427e
Content-Encoding: gzip
�V�M-.NLOU�RP�H����Q(��,V����\�҂⒢��\E�Z5[,%
- Etag is removed.
HTTP/1.1 200 OK
Server: nginx/1.17.6
Date: Wed, 01 Jan 2020 11:34:44 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: gzip
�V�M-.NLOU�RP�H����Q(��,V����\�҂⒢��\E�Z5[,%
- The weak etag passes through the proxy nginx.
curl http://localhost:80/weak_etag -i -H "Accept-Encoding: gzip"
HTTP/1.1 200 OK
Server: nginx/1.17.6
Date: Wed, 01 Jan 2020 11:54:12 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Etag: W/d41d8cd98f00b204e9800998ecf8427e
Content-Encoding: gzip
�V�M-.NLOU�RP�H����Q(��,V����\�҂⒢��\E�Z5[,%
- The strong etag passes through the proxy nginx.
$ curl http://localhost:80/strong_etag -i
HTTP/1.1 200 OK
Server: nginx/1.17.6
Date: Wed, 01 Jan 2020 11:56:29 GMT
Content-Type: application/json
Content-Length: 44
Connection: keep-alive
Etag: d41d8cd98f00b204e9800998ecf8427e
{"message": "Hello, this is from upstream!"}%