From patchwork Tue Jan 12 22:20:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Ponomarev X-Patchwork-Id: 1425492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.openwrt.org (client-ip=2001:8b0:10b:1231::1; helo=merlin.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=merlin.20170209 header.b=iMAr5Tfe; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=cVLs4Kh7; dkim-atps=neutral Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:8b0:10b:1231::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DFmMq59NXz9sVk for ; Wed, 13 Jan 2021 10:03:35 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=imGfb4YA+Q1otmlLA93hapkvPon1zEFeK2JT8CkDiT0=; b=iMAr5TfeNkpHsQqc3TTd6R8Hl J2XseTrCLWw547c/vByRYx/0rPPC4mZNlD0zMszXwfB1bYuiq1hHrESUecXhaOr4Z9ssQ1z3kVcVJ /2hC1ryNv/NLBByhlMYrxPXk5ctFv5Z2J89YVBFqEqZwIo+z86/XtlxsrWOP5dJagbJLx9TEFyZMi niEiHh6qHMRN/Z3gMNSYfuGcHIRzGxrZ07U/UB5Q5aXJ4yfPTV/V9Rfusbsz2zyAdaVVFvJvAnGld 9ir4WMOcXgvSL85PktRMACXR8xiwQe8N/RGBIAzP6fzzSySE+quPOprStPTowyPeOmMltPljR14Xy nddDRVPmw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzS2U-0003wW-Kr; Tue, 12 Jan 2021 22:21:22 +0000 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzS2M-0003rN-Ly for openwrt-devel@lists.openwrt.org; Tue, 12 Jan 2021 22:21:16 +0000 Received: by mail-ed1-x52e.google.com with SMTP id g21so1990981edy.0 for ; Tue, 12 Jan 2021 14:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=COE22TR3VsfUxeitimjwHqkyUCm/KxlyPocJs+r0EXg=; b=cVLs4Kh7C1hBYA8BN5PlwZme8KVKQk10Z+Q9jwhw716+hY9UG53SUyrjRkB2eM2xRu ojITIXuBxTCrMJ92CHWyun3u3rUQOIlSfYdZZpQ9KKG5SuVyTa/6D/s330fzLGnasqKy HxQe31ytcgZ+Z0GzfFb9AYwyaHAMZH+tEAQXqeotF9psLmeLL87UOK6w9oSvC1nUKXTX Yw3+IwB1Mt/w3JAGOhH6dSzr7QfyJOh5aTT1NoWnM6JR3hAJiiMhctpvVb2eij74zPlv iCeyXEu26kxls8HMhDUmQSrDk7/qe+4+5++Lk+M8hkybYagtvYbT8FFLhVflIBnZqed1 FYMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=COE22TR3VsfUxeitimjwHqkyUCm/KxlyPocJs+r0EXg=; b=PzNaBk9sNt9UScQV53UsChtgGp5q+tjppl6ZeeVWTNrr5wb0YEecFhdc0ZfH7IUrbp JmnOtL/uhi67vXrY4g8+zF4yRYQMkxvdEAQWNDFCRrlLac69TYVUJHB/ohn35O5Qo7E7 JajLjoUn+q+8dtxsH3mzmVOSbJM2I0OriiSo4zepaXz11rUkNdmUmj9n1lzHLrUIKb0/ ZjqFdOWX9UDKIlGeSOeLnP2KXp7yqcdDeuo3gg8ny7Bf6l0BRP157Yyd6XSATvLgU8no JxcQlmyjZ3Dyg1KjA20JCkrG2v6pVsdHJOLpUJL1vIM2fezyRknaYJloPc5sfeerwCX9 tSzw== X-Gm-Message-State: AOAM530SMLWYIfe6UsXTR89DI2GUwwB508U192O/GESxnt7cuh567Vde dj+pk5TD9ccrZ/9cYlxPzQAbMuEXOJwCKw== X-Google-Smtp-Source: ABdhPJwTQWv+Pa/86FNzukgQ+BO5hisPLQwfhNm5t7ypPVexVmrrwgU9i5Xha4omCmmqmYLUrFMaXQ== X-Received: by 2002:a05:6402:407:: with SMTP id q7mr1044560edv.312.1610490071545; Tue, 12 Jan 2021 14:21:11 -0800 (PST) Received: from localhost.localdomain ([46.98.213.161]) by smtp.gmail.com with ESMTPSA id t15sm6727eds.38.2021.01.12.14.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 14:21:11 -0800 (PST) From: Sergey Ponomarev To: openwrt-devel@lists.openwrt.org Subject: [PATCH 1/2] Make ETag load balancer friendly Date: Wed, 13 Jan 2021 00:20:56 +0200 Message-Id: <20210112222057.26876-2-stokito@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210112222057.26876-1-stokito@gmail.com> References: <20210112222057.26876-1-stokito@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210112_172114_792241_583F4686 X-CRM114-Status: GOOD ( 16.22 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:52e listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [stokito[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergey Ponomarev Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Current ETag contains file's INODE which is always different on machines even if content of the file the same. When you made a sysupgrade i.e. changed file system then on next visit to web page all files will be downloaded again because their ETag was changed even if not all files actually were changed. Another problem is that web site uses load balancer and there is two instances of uhttpd with the same content then ETag generated by one server will be discarded by another because the have different inode. To avoid this problem popular web servers Apache and Nginx not use inode anymore. --- file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/file.c b/file.c index 85487f8..759ffd6 100644 --- a/file.c +++ b/file.c @@ -300,8 +300,8 @@ static const char * uh_file_mime_lookup(const char *path) static const char * uh_file_mktag(struct stat *s, char *buf, int len) { - snprintf(buf, len, "\"%" PRIx64 "-%" PRIx64 "-%" PRIx64 "\"", - s->st_ino, s->st_size, (uint64_t)s->st_mtime); + snprintf(buf, len, "\"%" PRIx64 "-%" PRIx64 "\"", + s->st_size, (uint64_t)s->st_mtime); return buf; }