[OpenWrt-Devel] [PATCH 1/2] services/uhttpd: add -o option for Cache-Control header no-cache
Florian Eckert
fe at dev.tdt.de
Wed Jul 4 09:26:58 EDT 2018
If uhttpd is started with the option -o then Cache-Control header is
send with option no-cache to client. This option will instruct the client
software (browser) do not cache the content.
I have seen some problem with luci-ng with the Browsers Edge, IE and Firefox.
They will not load the new files even the file content has changed.
If I set this option then all browser will load the new file from uhttpd.
This works with the Etag header feature.
Signed-off-by: Florian Eckert <fe at dev.tdt.de>
---
...ble-to-send-Cache-Control-header-no_cache.patch | 43 ++++++++++++++++++++++
1 file changed, 43 insertions(+)
create mode 100644 package/network/services/uhttpd/patches/0001-make-uhttpd-configurable-to-send-Cache-Control-header-no_cache.patch
diff --git a/package/network/services/uhttpd/patches/0001-make-uhttpd-configurable-to-send-Cache-Control-header-no_cache.patch b/package/network/services/uhttpd/patches/0001-make-uhttpd-configurable-to-send-Cache-Control-header-no_cache.patch
new file mode 100644
index 0000000000..4c40abd2ac
--- /dev/null
+++ b/package/network/services/uhttpd/patches/0001-make-uhttpd-configurable-to-send-Cache-Control-header-no_cache.patch
@@ -0,0 +1,43 @@
+--- a/file.c
++++ b/file.c
+@@ -339,6 +339,8 @@ static void uh_file_response_ok_hdrs(str
+ ustream_printf(cl->us, "ETag: %s\r\n", uh_file_mktag(s, buf, sizeof(buf)));
+ ustream_printf(cl->us, "Last-Modified: %s\r\n",
+ uh_file_unix2date(s->st_mtime, buf, sizeof(buf)));
++ if(conf.no_cache)
++ ustream_printf(cl->us, "Cache-Control: %s\r\n", "no-cache");
+ }
+ ustream_printf(cl->us, "Date: %s\r\n",
+ uh_file_unix2date(time(NULL), buf, sizeof(buf)));
+--- a/main.c
++++ b/main.c
+@@ -232,7 +232,7 @@ int main(int argc, char **argv)
+ init_defaults_pre();
+ signal(SIGPIPE, SIG_IGN);
+
+- while ((ch = getopt(argc, argv, "A:aC:c:Dd:E:fh:H:I:i:K:k:L:l:m:N:n:p:qRr:Ss:T:t:U:u:Xx:y:")) != -1) {
++ while ((ch = getopt(argc, argv, "A:aC:c:Dd:E:fh:H:I:i:K:k:L:l:m:N:n:op:qRr:Ss:T:t:U:u:Xx:y:")) != -1) {
+ switch(ch) {
+ #ifdef HAVE_TLS
+ case 'C':
+@@ -311,6 +311,10 @@ int main(int argc, char **argv)
+ conf.rfc1918_filter = 1;
+ break;
+
++ case 'o':
++ conf.no_cache = 1;
++ break;
++
+ case 'n':
+ conf.max_script_requests = atoi(optarg);
+ break;
+--- a/uhttpd.h
++++ b/uhttpd.h
+@@ -77,6 +77,7 @@ struct config {
+ int ubus_noauth;
+ int ubus_cors;
+ int cgi_prefix_len;
++ int no_cache;
+ struct list_head cgi_alias;
+ };
+
--
2.11.0
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list