V
V
Vladislav2015-12-30 14:09:39
Apache HTTP Server
Vladislav, 2015-12-30 14:09:39

The server gives gzip, and the browser accepts text. What is the problem?

Chrome browser. We send 2 identical requests to the server with different User-Agents, Apache returns identical responses, and in Chrome DevTools we get different results, in one case the result is gzip compressed, and in the other not. Firefox has a similar situation.
It should be:

Request:
GET /min/g=css&1451385332 HTTP/1.1
Host: domain.ru:8080
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14
Accept-Encoding: gzip, deflate, sdch
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4

Response:
HTTP/1.1 200 OK
Date: Wed, 30 Dec 2015 10:26:44 GMT
Server: Apache
Expires: Thu, 29 Dec 2016 10:26:44 GMT
Vary: Accept-Encoding
Last-Modified: Tue, 29 Dec 2015 10:35:32 GMT
ETag: "pub1451385332;gz"
Cache-Control: max-age=31536000
Content-Length: 26530
Content-Encoding: gzip
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/css; charset=utf-8

Server log:
[rewrite:trace] mod_rewrite.c(475): - - [domain.ru/sid#7fe35e520f98][rid#7fe3
[filter:trace4] mod_filter.c(169): Content-Type 'text/css; charset=utf-8' ...
[filter:trace4] mod_filter.c(181): ... did not match 'application/xml'
[filter:trace2] mod_filter.c(188): Content-Type condition for 'deflate' did not match
[filter:trace4] mod_filter.c(169): Content-Type 'text/css; charset=utf-8' ...
[filter:trace4] mod_filter.c(181): ... did not match 'application/rss+xml'
[filter:trace2] mod_filter.c(188): Content-Type condition for 'deflate' did not match
[filter:trace4] mod_filter.c(169): Content-Type 'text/css; charset=utf-8' ...
[filter:trace4] mod_filter.c(181): ... did not match 'application/x-javascript'
[filter:trace4] mod_filter.c(181): ... did not match 'application/javascript'
[filter:trace4] mod_filter.c(181): ... did not match 'application/ecmascript'
[filter:trace2] mod_filter.c(188): Content-Type condition for 'deflate' did not match
[filter:trace4] mod_filter.c(169): Content-Type 'text/css; charset=utf-8' ...
[filter:trace4] mod_filter.c(175): ... matched 'text/css'
[filter:trace2] mod_filter.c(188): Content-Type condition for 'deflate' matched
[deflate:trace1] mod_deflate.c(677): Not compressing (content-encoding already  set: gzip)
[http:trace3] http_filters.c(1003): Response sent with status 200, headers:
[http:trace5] http_filters.c(1010):   Date: Wed, 30 Dec 2015 10:34:25 GMT
[http:trace5] http_filters.c(1013):   Server: Apache
[http:trace4] http_filters.c(832):   Expires: Thu, 29 Dec 2016 10:34:25 GMT
[http:trace4] http_filters.c(832):   Vary: Accept-Encoding
[http:trace4] http_filters.c(832):   Last-Modified: Tue, 29 Dec 2015 10:35:32 GMT
[http:trace4] http_filters.c(832):   ETag: \\"pub1451385332;gz\\"
[http:trace4] http_filters.c(832):   Cache-Control: max-age=31536000
[http:trace4] http_filters.c(832):   Content-Length: 26530
[http:trace4] http_filters.c(832):   Content-Encoding: gzip
[http:trace4] http_filters.c(832):   Keep-Alive: timeout=5, max=100
[http:trace4] http_filters.c(832):   Connection: Keep-Alive
[http:trace4] http_filters.c(832):   Content-Type: text/css; charset=utf-8

Request with regular User-Agent:
Request:
GET /min/g=css&1451385332 HTTP/1.1
Host: domain.ru:8080
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4

Response:
HTTP/1.1 200 OK
Date: Wed, 30 Dec 2015 10:40:15 GMT
Server: Apache
Expires: Thu, 29 Dec 2016 10:40:15 GMT
Vary: Accept-Encoding
Last-Modified: Tue, 29 Dec 2015 10:35:32 GMT
ETag: "pub1451385332;gz"
Cache-Control: max-age=31536000
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/css; charset=utf-8
Transfer-Encoding: chunked

Server log:
[rewrite:trace1] mod_rewrite.c(475):  - - [domain.ru/sid#7fe35e520f98][rid#7fe3
[filter:trace4] mod_filter.c(169):  Content-Type 'text/css; charset=utf-8' ...
[filter:trace4] mod_filter.c(181):  ... did not match 'application/xml'
[filter:trace2] mod_filter.c(188):  Content-Type condition for 'deflate' did not match
[filter:trace4] mod_filter.c(169):  Content-Type 'text/css; charset=utf-8' ...
[filter:trace4] mod_filter.c(181):  ... did not match 'application/rss+xml'
[filter:trace2] mod_filter.c(188):  Content-Type condition for 'deflate' did not match
[filter:trace4] mod_filter.c(169):  Content-Type 'text/css; charset=utf-8' ...
[filter:trace4] mod_filter.c(181):  ... did not match 'application/x-javascript'
[filter:trace4] mod_filter.c(181):  ... did not match 'application/javascript'
[filter:trace4] mod_filter.c(181):  ... did not match 'application/ecmascript'
[filter:trace2] mod_filter.c(188):  Content-Type condition for 'deflate' did not match
[filter:trace4] mod_filter.c(169):  Content-Type 'text/css; charset=utf-8' ...
[filter:trace4] mod_filter.c(175):  ... matched 'text/css'
[filter:trace2] mod_filter.c(188):  Content-Type condition for 'deflate' matched
[deflate:trace1] mod_deflate.c(677):  Not compressing (content-encoding already  set: gzip)
[http:trace3] http_filters.c(1003):  Response sent with status 200, headers:
[http:trace5] http_filters.c(1010):    Date: Wed, 30 Dec 2015 10:40:15 GMT
[http:trace5] http_filters.c(1013):    Server: Apache
[http:trace4] http_filters.c(832):    Expires: Thu, 29 Dec 2016 10:40:15 GMT
[http:trace4] http_filters.c(832):    Vary: Accept-Encoding
[http:trace4] http_filters.c(832):    Last-Modified: Tue, 29 Dec 2015 10:35:32 GMT
[http:trace4] http_filters.c(832):    ETag: \\"pub1451385332;gz\\"
[http:trace4] http_filters.c(832):    Cache-Control: max-age=31536000
[http:trace4] http_filters.c(832):    Content-Length: 26530
[http:trace4] http_filters.c(832):    Content-Encoding: gzip
[http:trace4] http_filters.c(832):    Keep-Alive: timeout=5, max=100
[http:trace4] http_filters.c(832):    Connection: Keep-Alive
[http:trace4] http_filters.c(832):    Content-Type: text/css; charset=utf-8

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivanq, 2015-12-30
@Ivanq

The server is checking for a browser. The fact is that some browsers, perhaps even sending Accept-Encoding, do not support gzip itself. Then we decided to determine by User-Agent. The browser sees a certain word in the User-Agent and disables gzip.

V
Vladislav, 2015-12-30
@abo

Delivered wireshark, shows that gzip comes. Apparently this is just a display problem in DevTools, but still I would like to fix it
Here is an example, DevTools also shows 128 kb without gzip habracdn.net/toster/frontend.946529c4-a992-11e5-81...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question