3

I use a module which make only a request to a http service. In this module I have a variable with a date since the last request. After the module is "done" also the variable will get lost. But I want to save the date in that variable since the last request.

something like that:

moduleA.js:

var lastModifiedSince = null;
...
//request goes here
...
//if request was successfull
  lastModifiedSince = new Date();

So but the next time I do a request the script starts new and lastModifiedSince will be null at the first time.

It's ok to be null if the server have to be restarted but I want to keep the date until the server is alive not only as long as the module is working. So what would be best practice to solve this?

WeSt
  • 889
  • 5
  • 14
  • 32
  • 2
    Once a module is loaded, it should stay loaded until something explicitly [removes it from the cache](https://stackoverflow.com/questions/6676612/unloading-code-modules) or the application restarts. This should work fine the way you have it – CodingIntrigue Oct 09 '17 at 10:44
  • you are correct. post this as answer and I will accept it – WeSt Oct 09 '17 at 13:29

0 Answers0