File Outside the Static Folder - Caching problem


My app refresh a csv file every X minutes for a dataviz. Without private browsing, I can't display the dataviz with the last update.

With pythonanywhere, how can I disable the cache ? I tried things, but without success :/



one simple way would be to give it a different filename somehow? you could have a constant url that redirects to a different filename every time it's refereshed.

the alternative would be to serve the file yourself directly from python rather than going through our static files service. then you can control all the response headers, including the cache control ones...

Yes, I thought about a different filename, it will work.

Can you tell me more about the alternative ? I'm new in python/pythonanywhere, I've seen that it is possible to control the response headers from flask, but the codes I found don't work.

Under what conditions can we control the response headers ?

In my case, I have my which returns the csv file (via "send_from_directory") and returns the main_page.html (via "render_template"). This html page uses the csv and static files.

Thanks for the help

you'd probably have to look at the flask documentation for more info, but I think you can set a cache_timeout parameter in that send_from_directory function: