Add quotes to etags#220
Conversation
Etags must be quoted (reference: RFC 9110 §8.8.3) Before: etag: fa74dbac After: etag: "fa74dbac"
|
Not sure if we should add a W/ before to make it a weak tag, but we can discuss this later. Merged. |
|
My understanding is that strong etags are appropriate when: In the case of (b), strong etags may still be used with different encodings as long as the etag itself also changes. With digest-based etags, that can be as simple as adding a suffix, like "originalDigest-gzip", although a fresh digest of the compressed content would be valid too (it's just hard to match a fresh digest back to the original if needed). If an etag is reused across encodings, then it should be weak (or converted to weak). As a general rule, this conversion should be the responsibility of whatever's transforming the encodings. Strong etags can allow for content to be cached more often or for longer, and are desirable for things like static assets. Since propshaft doesn't involve itself with compression or any other alternate encodings, and since the digest-sourced etag will definitely change if the content changes, a strong etag seems appropriate. |
|
Your final paragraph addresses the thing I had been wondering: CDNs that automatically serve optimized versions of image files. I agree that since it’s not Propshaft making that change, then Propshaft can use strong tags and the CDN can handle their part. |
This PR fixes etag generation in Propshaft::Server.
In contrast to other headers, etags must be quoted. (See RFC 9110 §8.8.3.)
Before:
etag: fa74dbacAfter:
etag: "fa74dbac"