Hi @fool,
Been doing some more experimenting because I don’t have anything to lose yet.
I’ve gotten rid of asset bundling and I’ve moved all libraries such as Bootstrap, Font Awesome, jQuery, etc., back onto Netlify. I’ve removed all custom cache rules from the netlify.toml file. With the exception of my service worker, all behavior should be very vanilla.
With that in mind, I execute the following command:
$ curl -I https://www.thepolyglotdeveloper.com/css/bootstrap/bootstrap.min.css
HTTP/2 200
accept-ranges: bytes
cache-control: public, max-age=0, must-revalidate
content-length: 121457
content-type: text/css; charset=UTF-8
date: Fri, 30 Aug 2019 20:48:56 GMT
etag: "1be33a500fe9965531b55b00eb157868-ssl"
strict-transport-security: max-age=31536000
age: 0
server: Netlify
x-nf-request-id: e9648d51-c3f5-40de-b217-f552987d4c70-2783111
It seems fine, although, I don’t have the knowledge on this kind of stuff to say that it isn’t fine.
So now, I take information from the previous request and execute the following:
$ curl -I -H 'If-None-Match: "1be33a500fe9965531b55b00eb157868-ssl"' https://www.thepolyglotdeveloper.com/css/bootstrap/bootstrap.min.css
HTTP/2 304
cache-control: public, max-age=0, must-revalidate
date: Fri, 30 Aug 2019 21:06:07 GMT
etag: "1be33a500fe9965531b55b00eb157868-ssl"
strict-transport-security: max-age=31536000
age: 0
server: Netlify
x-nf-request-id: eaa63499-41f5-44e6-838e-9fffcaf493fd-3156240
As you can see, I’ve taken the etag
value from the first request and tested in the second request to see if I get a 304 response, which I did.
I’ve re-read your articles at least 25 times now and as far as I can tell, when a request is sent with the etag
, it returns a 304 if the hash hasn’t changed which signals to the requestor to use what exists in cache. If anything other than a 304 comes back, use the fresh copy and store the new etag
value.
So here is where it gets strange.
When I open my browser (tried Chrome and Firefox) and look at the etag
value, it doesn’t quite match. Instead, I have the following:
1be33a500fe9965531b55b00eb157868-ssl-df
Notice that it is essentially the same as the etag
that came back in the cURL request, except this one has a -df
appended to the end.
So I take the new etag
and run the request in cURL:
$ curl -I -H 'If-None-Match: "1be33a500fe9965531b55b00eb157868-ssl-df"' https://www.thepolyglotdeveloper.com/css/bootstrap/bootstrap.min.css
HTTP/2 200
accept-ranges: bytes
cache-control: public, max-age=0, must-revalidate
content-length: 121457
content-type: text/css; charset=UTF-8
date: Fri, 30 Aug 2019 21:10:44 GMT
etag: "1be33a500fe9965531b55b00eb157868-ssl"
strict-transport-security: max-age=31536000
age: 0
server: Netlify
x-nf-request-id: eaa63499-41f5-44e6-838e-9fffcaf493fd-3236395
The -df
at the end is invalid and the entire resource is obtained again because a 304 response code was not used.
So is there something wrong with the etag
feature of Netlify? My browsers appear to be requesting a new resource every time because the etag
value doesn’t match cURL. If this is true, it would probably explain my heavy bandwidth usage.
Can you please validate my research and tell me if I’m correct or incorrect? If I’m incorrect, can you please explain why I’m seeing what I’m seeing as well as how to correctly do these tests?
Thanks,