Accessing latest files based on timestamp

by Tan   Last Updated April 15, 2019 20:05 PM

I have a download button in the UI, user clicks on it and download 3 files in a zip format.

It's not necessary that the files are arleady there when download button is clicked because the backend process can take sometime to put the files at a particular location on the server.

Files are going to be in following format


So that each time a user clicks on the button, I can get the latest file based on the timestamp.

I am trying to figure out where exactly I should generate this timestamp?This timestamp is going to be included with the file name at the time of file generation.

1) Should I generate it using javascript and send it along with the webservice call which is responsible to start the back end process and put the files somewhere on the server?

The problem with this approach is that how would I know the timestamp value if a user shuts down his computer and come back later looking for files after clicking the download button ?


2) Should I have my back end java based webservice generate the timestamp as soon as it's called from the UI?

The problem with this approach is that I will need access to this timestamp on the UI side so that when a user clicks on the download button, I can make a request based on the file name and let the user know whether the file exists or not. One approach is to get this timestamp from the Java webservice in json response but this would only work when the user keeps the browser open for long time which is not ideal. Let's say user shuts down everything and come back later. How should I handle this thing ?

If there's any additional thing I would need to do(which I think I would have to) in addition to handling timestamp generation, please let me know. Thanks

My front end is just using HTML,CSS,Javascript and backend is using springboot java webservices.Let me know if I can answer more questions.

Related Questions

Updated April 16, 2017 21:05 PM

Updated May 23, 2016 08:02 AM

Updated March 27, 2015 07:01 AM

Updated March 28, 2015 13:01 PM

Updated April 24, 2015 02:02 AM