Apache + Etags -> returns 200 and send content ins

2019-07-04 02:15发布

问题:

I have this Apache conf that uses Etags:

<VirtualHost *:8080>
        ServerName xxx.co
        SSLEngine On
        SSLProtocol all -SSLv2
        SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
        SSLCertificateFile /etc/apache2/xxx.crt
        SSLCertificateKeyFile /etc/apache2/xxx.key
        SSLCertificateChainFile /etc/apache2/sub.class1.server.ca.pem
        SSLCACertificateFile /etc/apache2/ca.pem
        SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

  ServerAdmin edward@xxx.co
  DocumentRoot /home/ubuntu/xxx-react/build/  
  Header set Access-Control-Allow-Origin "*"
  FileETag MTime Size
</VirtualHost> 

I have this request/response from Chrome debugger:

Remote Address:xxx:8080
Request URL:https://xxx.co:8080/app.js
Request Method:GET
Status Code:200 OK

Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip,deflate
Accept-Language:en,fr-FR;q=0.8,fr;q=0.6,en-US;q=0.4,ms;q=0.2
Cache-Control:max-age=0
Connection:keep-alive
Host:xxx.co:8080
If-Modified-Since:Fri, 26 Sep 2014 10:42:18 GMT
If-None-Match:"5a59c6-503f59239d4ce-gzip"
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36

Response Headersview source
Accept-Ranges:bytes
Access-Control-Allow-Origin:*
Connection:Keep-Alive
Content-Encoding:gzip
Content-Type:application/javascript
Date:Fri, 26 Sep 2014 15:49:45 GMT
ETag:"5a59c6-503f59239d4ce-gzip"
Keep-Alive:timeout=5, max=100
Last-Modified:Fri, 26 Sep 2014 10:42:18 GMT
Server:Apache/2.4.6 (Ubuntu)
Transfer-Encoding:chunked
Vary:Accept-Encoding

As we can see, the Etag sent in the header matches the file in the response, so can someone please explain me why Apache returns 200 instead of 304, and thus produce a cache miss while the cache should work?

Thanks