diff mbox series

[1/2] Make ETag load balancer friendly

Message ID 20210112222057.26876-2-stokito@gmail.com
State New
Headers show
Series uhttpd: Generate ETag similar to Nginx and BusyBox HTTPD | expand

Commit Message

Sergey Ponomarev Jan. 12, 2021, 10:20 p.m. UTC
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 mbox series


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;