flask.Flask.get_send_file_max_age¶
-
Flask.get_send_file_max_age(filename)¶ Provides default cache_timeout for the
send_file()functions.By default, this function returns
SEND_FILE_MAX_AGE_DEFAULTfrom the configuration ofcurrent_app.Static file functions such as
send_from_directory()use this function, andsend_file()calls this function oncurrent_appwhen the given cache_timeout isNone. If a cache_timeout is given insend_file(), that timeout is used; otherwise, this method is called.This allows subclasses to change the behavior when sending files based on the filename. For example, to set the cache timeout for .js files to 60 seconds:
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)
New in version 0.9.