gzip compression doesn't work and can't get 304 in chrome gzip compression doesn't work and can't get 304 in chrome google-chrome google-chrome

gzip compression doesn't work and can't get 304 in chrome


I always use Fiddler to inspect these kind of challenges.

The F5/If-Modified-Since issue.

Chrome just doesn't make a new request if the expires header has been set and its datetime value is still actual. So Chrome is respecting your expected caching behaviour. When navigating over your website via an other browser, you 'll see that also these don't send any requests for these assets. F5 is 'special', it's a forced refresh.

The chunked/gzip issue

Clear your browser cache and inspect the first response. Fiddler will show 'Response body is encoded', which means compressed (gzip or deflate).

Whether you see Transfer-Encoding chunked depends on whether the Content-Length header is present. See the difference in the responses below. If you don't want the chunked Transfer-Encoding set the Content-Length header.

Content-Type: text/javascript; charset=utf-8Content-Encoding: gzipExpires: Sat, 25 May 2019 13:14:11 GMTLast-Modified: Fri, 25 May 2018 13:14:11 GMTVary: Accept-EncodingServer: Microsoft-IIS/10.0Content-Length: 5292Content-Type: text/javascript; charset=utf-8Transfer-Encoding: chunkedContent-Encoding: gzipExpires: Sat, 25 May 2019 13:14:11 GMTLast-Modified: Fri, 25 May 2018 13:14:11 GMTVary: Accept-EncodingServer: Microsoft-IIS/10.0

Because you are handling the serving of assets via your own code, instead of via the IIS static files module, you have to deal with all response headers yourself.