I've observed a very interesting behavior from Chrome that I do not observe from other browsers.
Chrome seems to cache downloads from the same URL on webservers hosted using Flask. For instance:
@app.route('/download/<string:filename>')
def download(filename):
send_file(filename)
Essentially, if I visit localhost:3000/download/a_file.exe, then a_file.exe gets downloaded.
However, the problem is, if I modify a_file.exe (making it a new binary), then the old binary gets downloaded. Same goes for any file format, really. I originally found out this problem when I tried to replace a picture that I was attempting to download (let's say, hi.jpg). Even if I change hi.jpg to a new picture, the old one gets downloaded.
It gets even funnier.
If I delete the file, a_file.exe, from my project folder. Theoretically it should throw an error, right? Nope, still downloads the old a_file.exe, even if the file doesn't even exist.
If I stop the server, modify the download() function, restart the server
@app.route('/download/<string:filename>)
def download(filename):
print("hi")
send_file(filename)
Now what should happen is "hi" gets printed, but it doesn't, meaning Chrome basically completely bypasses actually sending a request to the server and just gives you the file.
The funniest thing is, even if completely shut down the server, it still downloads!!
On a serious note, this is pretty problematic (at least for me), as my server is essentially constantly modifying the same file and basically users should be able to get the most current version instead of just some random version they cached.
Again, this does not occur on other browsers, such as Edge (which also uses Chromium). I have tested myself.
If there is any solution that doesn't involve changing the file name itself (as that will probably solve it but is a bit problematic for me to implement), please let me know. Thanks in advance.