[PATCH 1/2] Make ETag load balancer friendly

Sergey Ponomarev stokito at gmail.com
Tue Jan 12 17:20:56 EST 2021


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;
 }
-- 
2.27.0




More information about the openwrt-devel mailing list