I'm trying to set a reasonable cache expiry for my JS files while in development. I have the standard setup, where HTML, CSS and JS are living under the
The docs do mention this, but for the life of me I cannot get this to work. I've tried both methods implied, first
class MyFlask(flask.Flask): def get_send_file_max_age(self, name): if name.lower().endswith('.js'): return 60 return flask.Flask.get_send_file_max_age(self, name) app = MyFlask(__name__)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 60
Both have had no effect, my JS files under /static are still coming back with the default cache timeout,
Cache-Control: public, max-age=43200
Any pointers appreciated.
I had this problem and couldn't find an answer online that worked for me.
Then I realised that my static files are not being served from Flask at all! Flask only generates my HTML. The static files are served directly by my web server (Apache in my case, yours might be Nginx or something else).
Here are the instructions for Apache.
First install the mod_expires module:
sudo a2enmod expires
Then add something like this to your
More details on how to configure it in the Apache manual.