3

What does the "Disable Cache" have to do with gzip and compression? How come if "Disable Cache" is checked the Response Headers shows content-encoding: gzip, but when "Disable Cache" is not checked(2nd screenshot) the Response Headers does not show content-encoding: gzip? Which one is correct or how do I make both of them to show gzip? Thank you.

enter image description here enter image description here

2

What does the "Disable Cache" have to do with gzip and compression?

Nothing directly. Except that when "Disable Cache" is checked (ie. the local browser cache is disabled) the server is forced to send a fresh response (and body). You'd get the same response if you simply cleared your browser cache before making the request (with "Disable Cache" unchecked).

Conversely, when the local cache is enabled then the server may not send a complete response (which is what's happening here). In some situations the browser may not send a request at all (depending on the caching mechanism).

How come if "Disable Cache" is checked the Response Headers shows content-encoding: gzip

Because the server is forced to send a complete/fresh response, including a full response body. It is the response body that is gzip'd.

but when "Disable Cache" is not checked(2nd screenshot) the Response Headers does not show content-encoding: gzip?

In this instance your server is responding with Status: 304 "Not Modified" as the locally cached copy is deemed fresh. With a 304, the server does not send a response body (there is no Content-Length header) and consequently there is no content to gzip. The response is ultimately pulled from the browser cache.

Which one is correct or how do I make both of them to show gzip?

Both are correct. One is a complete server response and body, the other is a short (HEAD only) 304 response indicating that the locally cached version should be used instead.

  • 1
    I think the cached response is a little more nuanced. The server responds with a "304" which means, "This document hasn't changed, go ahead and use the cached version". The server doesn't use gzip for that because there is no content payload. The response headers themselves aren't from the cache, which is what I'm reading from your answer. – Stephen Ostermiller Jun 21 '18 at 14:03
  • @StephenOstermiller Thanks, yes, that makes more sense. My answer was misleading - I've rewritten it. – DocRoot Oct 27 '18 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.