Skip to content

Commit

Permalink
[assets] confirm a weak but matching ETag
Browse files Browse the repository at this point in the history
When handling compression at the proxy server level, the client receives a weak ETag.
Weak ETags are prefixed with `W/`, e.g. `W/"2.2.0"`.
Upon cache validation we should take care of these too.
  • Loading branch information
das7pad committed Sep 7, 2019
1 parent 9c1e73c commit 25e8050
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/index.js
Expand Up @@ -358,10 +358,11 @@ Server.prototype.serve = function(req, res){
// Per the standard, ETags must be quoted:
// https://tools.ietf.org/html/rfc7232#section-2.3
var expectedEtag = '"' + clientVersion + '"';
var weakEtag = 'W/' + expectedEtag;

var etag = req.headers['if-none-match'];
if (etag) {
if (expectedEtag == etag) {
if (expectedEtag == etag || weakEtag == etag) {
debug('serve client 304');
res.writeHead(304);
res.end();
Expand Down

0 comments on commit 25e8050

Please sign in to comment.