Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  25 Jan 2021, Thomas Lindner, Suggestion, mhttpd browser caching 
    Reply  25 Jan 2021, Stefan Ritt, Suggestion, mhttpd browser caching 
       Reply  25 Jan 2021, Thomas Lindner, Suggestion, mhttpd browser caching 
    Reply  08 Feb 2021, Konstantin Olchanski, Suggestion, mhttpd browser caching 
       Reply  08 Feb 2021, Stefan Ritt, Suggestion, mhttpd browser caching 
Message ID: 2079     Entry time: 25 Jan 2021     Reply to this: 2080   2085
Author: Thomas Lindner 
Topic: Suggestion 
Subject: mhttpd browser caching 
I have a more subtle point about the new ODB key for using an external elog I mentioned in [1].  I was very confused after changing the ODB "External Elog" because mhttpd still wasn't using my external elog URL.  I started trying to debug mhttpd.cxx, but found a lot of bits of mhttpd didn't seem to be getting called.  I eventually realized that my browser had been caching the responses for some (though not all) of the MIDAS navigation buttons.  Clearing my browser cache fixed the problem and allowed me to use the MIDAS button to the external ELOG.  This caching happens on my macbook for both Firefox 84.0.2 and Safari 13.1.

Many of the requests to mhttpd end up going to send_fp(), where we explicitly set the cache time to 24 hours.

   // send HTTP cache control headers                                                                                               
   time_t now = time(NULL);
   now += (int) (3600 * 24);
   struct tm* gmt = gmtime(&now);
   const char* format = "%A, %d-%b-%y %H:%M:%S GMT";
   char str[256];
   strftime(str, sizeof(str), format, gmt);
   r->rsprintf("Expires: %s\r\n", str);

Some other MIDAS buttons don't seem to be cached by the browser; for instance the response for the 'OldHistory' button doesn't get cached.

Should we remove the cache instruction for at least some of the buttons?  At least for the elog button where we want the link direction to get switched by an ODB key the caching seems a bad idea.

[1] https://midas.triumf.ca/elog/Midas/2078
ELOG V3.1.4-2e1708b5