diff --git a/winixd/core/app.cpp b/winixd/core/app.cpp index f06416d..4c16c7f 100644 --- a/winixd/core/app.cpp +++ b/winixd/core/app.cpp @@ -1180,6 +1180,11 @@ void App::CheckHtmx() { // fastcgi will change the header to hx_request cur.request->is_htmx_request = (cur.request->headers_in.has_key(L"HX-Request") || cur.request->headers_in.has_key(L"hx_request")); + + if( cur.request->is_htmx_request && config.add_header_cache_no_store_in_htmx_request ) + { + cur.request->out_headers.add(L"Cache-Control", L"no-store, max-age=0"); + } } diff --git a/winixd/core/config.cpp b/winixd/core/config.cpp index e1d300a..973afd4 100644 --- a/winixd/core/config.cpp +++ b/winixd/core/config.cpp @@ -313,6 +313,7 @@ void Config::AssignValues(bool stdout_is_closed) proxy_ip_header = Text(L"proxy_ip_header", L"X_Real_IP"); antispam_list_max_size = Size(L"antispam_list_max_size", 10); + add_header_cache_no_store_in_htmx_request = Bool(L"add_header_cache_no_store_in_htmx_request", true); } diff --git a/winixd/core/config.h b/winixd/core/config.h index c7ffa8e..7e7f09e 100644 --- a/winixd/core/config.h +++ b/winixd/core/config.h @@ -774,6 +774,13 @@ public: size_t antispam_list_max_size; + // send "Cache-Control: no-store, max-age=0" http header if a request is made by htmx library (ajax) + // if a webbrowser get a page from the cache then it will render just the last request without the whole html page (css, js, etc) + // https://github.com/bigskysoftware/htmx/issues/497 + bool add_header_cache_no_store_in_htmx_request; + + + Config(); bool ReadConfig(bool errors_to_stdout_, bool stdout_is_closed = true);