WebFaction
Community site: login faq

Hi, My static/php scripts use to send a weak etag, but it is removed by Nginx.

Is there a way to resolve this issue?

Thanks, Francesco

asked 02 Sep '15, 09:37

fra_t
1314
accept rate: 0%

edited 02 Sep '15, 09:38

If possible, could you please amend your question to include a URL that demonstrates the problem that you are reporting?

If you would rather not share that info here in the public forum, then feel free to open a support ticket instead.

(02 Sep '15, 15:54) seanf
(02 Sep '15, 16:52) fra_t

When I used web-sniffer.net and disabled 'Accept-Encoding: gzip' it worked.

I was also able to reproduce this with curl,

~/ curl -I www.sosbiglietti.it
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 03 Sep 2015 02:24:41 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
Expires: Fri, 04 Sep 2015 06:30:00 +0200
x-from-cache: 1
Etag: W/c308e95ef263d84fa7676668e6922462
x-cache-datetime: Wed, 02 Sep 2015 11:03:29 +0200
Last-Modified: Wed, 02 Sep 2015 04:05:07 GMT

~/ curl -H "Accept-Encoding: gzip" -I www.sosbiglietti.it
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 03 Sep 2015 02:25:33 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding
Expires: Fri, 04 Sep 2015 06:30:00 +0200
x-from-cache: 1
x-cache-datetime: Wed, 02 Sep 2015 11:03:29 +0200
Last-Modified: Wed, 02 Sep 2015 04:05:07 GMT
Content-Encoding: gzip

So it appears to be based on client settings and not the server. Based on this observation I found a blog post which explains this,

http://thinkingandcomputing.com/2014/09/27/enable-etag-nginx-resources-sent-gzip/

""" The issue was discussed over several forum threads and trackers. It appeared that Nginx deliberately strips ETags once gzip is applied, The motivation behind was that ETag should serve as a byte-accurate comparison, and since the result of gzip is not guaranteed to be identical under different configurations, ETag is no longer a strong validator and Nginx decided that it was simpler to remove it as opposed to converting it to a weak one. """

So, since Etag is essentially meaningless for gzip-encoded responses, Nginx strips it by design

permanent link

answered 03 Sep '15, 02:33

johns
5.3k312
accept rate: 23%

This should be fixed in the version 1.7 of Nginx: https://github.com/nulab/nginx-gzip-filter-allow-weak-etag-patch

""""Nginx gzip filter module removes ETag every time gzip compression being applied whether the ETag is strong or weak. However, a weak ETag validator doesn't require that the resources to be compared are byte-for-byte identical. Hence a weak ETag header should be kept during gzip compression. Actually the latest version of nginx (1.7.x) has ETag downgrade functionality instead of clearing all ETag""""

(03 Sep '15, 08:34) fra_t

Yes, the design decisions were changed in a later version of Nginx, but it's not a bug (per se) in Nginx 1.4, which your server runs. When Nginx is upgraded in the future to 1.7+, then this behavior will change automatically.

Since all requests go through the front-end Nginx, there's no workaround to allow weak ETag support. I've created an internal ticket for our system administration team to consider upgrading Nginx to 1.7 or later per your request, but there needs to be enough interest to justify the change. If others need weak ETag support (or other Nginx 1.5+ features), please leave comments with a description below.

(03 Sep '15, 09:09) ryans ♦♦

Thank you Ryans. Also, consider that the ETAG support can potentially save a lot of bandwidth :-)

(04 Sep '15, 09:22) fra_t

Thank you, now the ETAG is always present in the response :-)

(05 Oct '15, 17:04) fra_t

Nginx isn't dropping your etag.

Here is the response directly from Apache on your server:

[root@web441 ~]# GET -Ssed -H "Host: www.sosbiglietti.it" http://127.0.0.1:80
GET http://127.0.0.1:80 --> 200 OK
Connection: close
Date: Wed, 02 Sep 2015 18:20:13 GMT
ETag: W/c308e95ef263d84fa7676668e6922462
Server: Apache
Content-Type: text/html; charset=UTF-8
Expires: Thu, 03 Sep 2015 06:30:00 +0200
Last-Modified: Wed, 02 Sep 2015 04:05:07 GMT
Client-Date: Wed, 02 Sep 2015 18:20:13 GMT
Client-Peer: 127.0.0.1:80
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
Link: <http://www.sosbiglietti.it/>; rel="canonical"
Link: <http://www.sosbiglietti.it/assets/images/favicon.png>; rel="shortcut icon"; type="image/png"
Link: <http://www.sosbiglietti.it/assets/css/main.19.css>; rel="stylesheet"
Link: <http://fonts.googleapis.com/css?family=Open+Sans>; rel="stylesheet"
Link: <http://www.sosbiglietti.it/biglietti/json.php>; rel="prefetch"
Link: <http://www.sosbiglietti.it/biglietti/opensearch.php>; rel="search"; title="SOS Biglietti"; type="application/opensearchdescription+xml"
Title: SOS Biglietti - Biglietti concerti ed eventi, anche sold out al miglior prezzo
X-Cache-Datetime: Wed, 02 Sep 2015 11:03:29 +0200
X-From-Cache: 1
X-Meta-Charset: utf-8
X-Meta-Description: SOS Biglietti ti permette di confrontare in un click i prezzi dei principali siti di vendita biglietti per concerti, teatro, partite di calcio e sport.
X-Meta-Viewport: width=device-width, initial-scale=1, user-scalable=yes

... and here is the response from Nginx:

[root@web441 ~]# GET -Ssed http://www.sosbiglietti.it
GET http://www.sosbiglietti.it --> 200 OK
Connection: close
Date: Wed, 02 Sep 2015 18:20:36 GMT
ETag: W/c308e95ef263d84fa7676668e6922462
Server: nginx
Vary: Accept-Encoding
Content-Type: text/html; charset=UTF-8
Expires: Thu, 03 Sep 2015 06:30:00 +0200
Last-Modified: Wed, 02 Sep 2015 04:05:07 GMT
Client-Date: Wed, 02 Sep 2015 18:20:36 GMT
Client-Peer: 37.58.75.246:80
Client-Response-Num: 1
Client-Transfer-Encoding: chunked
Link: <http://www.sosbiglietti.it/>; rel="canonical"
Link: <http://www.sosbiglietti.it/assets/images/favicon.png>; rel="shortcut icon"; type="image/png"
Link: <http://www.sosbiglietti.it/assets/css/main.19.css>; rel="stylesheet"
Link: <http://fonts.googleapis.com/css?family=Open+Sans>; rel="stylesheet"
Link: <http://www.sosbiglietti.it/biglietti/json.php>; rel="prefetch"
Link: <http://www.sosbiglietti.it/biglietti/opensearch.php>; rel="search"; title="SOS Biglietti"; type="application/opensearchdescription+xml"
Title: SOS Biglietti - Biglietti concerti ed eventi, anche sold out al miglior prezzo
X-Cache-Datetime: Wed, 02 Sep 2015 11:03:29 +0200
X-From-Cache: 1
X-Meta-Charset: utf-8
X-Meta-Description: SOS Biglietti ti permette di confrontare in un click i prezzi dei principali siti di vendita biglietti per concerti, teatro, partite di calcio e sport.
X-Meta-Viewport: width=device-width, initial-scale=1, user-scalable=yes

Both of them include the "ETag: W/c308e95ef263d84fa7676668e6922462" header.

permanent link

answered 02 Sep '15, 18:26

seanf
12.2k41836
accept rate: 37%

Now I made some checks with different tools, and they give me different results:

http://www.webconfs.com/http-header-check.php -> ETag included http://web-sniffer.net/ -> No ETag Firebug in my browser (IP from Italy) -> No ETag

It seems like sometimes the ETags is included and sometimes is not. Maybe the IP/geolocation is the problem?

Here is the Firebug responce I get:

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 02 Sep 2015 21:53:22 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Expires: Thu, 03 Sep 2015 06:30:00 +0200
x-from-cache: 1
x-cache-datetime: Wed, 02 Sep 2015 11:03:29 +0200
Last-Modified: Wed, 02 Sep 2015 04:05:07 GMT
Content-Encoding: gzip
(02 Sep '15, 22:10) fra_t
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×186
×2

question asked: 02 Sep '15, 09:37

question was seen: 5,188 times

last updated: 05 Oct '15, 17:04

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM