I am creating the following anchor tag dynamically, to download the file I receive from flask backend. The url in a.href
is always constant. But the content of output.mp4
keeps on changing.
However, the content of file I get on a.click() is not changing. The file I get is the one I created atleast 3-4 hours ago. How do I get the updated file, on each a.click()
call?
var a = document.createElement('a')
a.href = 'http://localhost:5000/download/output'
a.setAttribute('download', 'output.mp4')
a.click()
This is almost 100% to do with the cache setup on the backend.
A simple solution would be to append a cache breaking flag on the output, such as
a.setAttribute('download', 'output.mp4?cachebuster=' + Date.now())