THttpServer and online modified files

Dear ROOT community,

I am working on a GUI using THttpServer, when I open my web page on my browser, and access some .log/.txt files from it, I don’t see them to be updated automatically once I write into those files, I need to refresh the page to get the last changes. Is there a way to make it more “dynamical” please ? Here is a snippet of the code I am using:

WebInterfaceServer::WebInterfaceServer(int port)
    : TNamed("WebInterfaceServer", "WebInterfaceServer") {

  m_http_server = new THttpServer(("http:" + std::to_string(port) + "?nocache;global").c_str()); 

  std::string files_path = "/PATH/TO/MY/FILE";

  m_http_server->AddLocation("Index/", files_path.c_str());

  std::string webinterface_path = "/PATH/TO/MY/WebPage.html";

  m_http_server->SetDefaultPage(webinterface_path.c_str());
}

Any kind of help or suggestion will be highly appreciated, thank you.

Best regards,
Abdelhamid.

Dear Abdelhamid,

Thanks for the post. This is a very specific question to which I hope @linev can reply.

Best,
Danilo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

Hi,

Most probably, you see browser caching problem.
Once file read, next time you get file content from the cache - not from network.
Simple workaround - you can add unique URL parameter like http://localhost:8080/subdir/file.txt?par=123. Changing such parameter you always get new content from the server.

Unfortunately, nocache parameter does not affect plain files access.
I will try to fix it.

Regards,
Sergey

Actually, how you access your files?

I checked once again - nocache set following http headers also for file access:

HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate, private, max-age=0
Expires: 0
Pragma: no-cache
Content-Type: image/x-icon
Last-Modified: Thu, 17 Oct 2019 06:43:52 GMT
Etag: "5da80da8.32038"
Content-Length: 32038
Accept-Ranges: bytes
Date: Wed, 17 Apr 2024 11:10:09 GMT

But it responsibility of the browser to correctly process it.
Anyway - workaround with file.txt?par=<unique> should work in all cases.

P.S. Sorry for late reply - I was in 3-weeks vacation