我正在尝试在开发过程中为我的JS文件设置合理的缓存过期.我有标准设置,HTML,CSS和JS都在static目录下.
该文档也提到这一点,但我的生活,我不能得到这个工作.我先尝试过隐含的两种方法
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__)
Run Code Online (Sandbox Code Playgroud)
和
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 60
Run Code Online (Sandbox Code Playgroud)
两者都没有效果,我在/ static下的JS文件仍然会返回默认的缓存超时,
Cache-Control: public, max-age=43200
Run Code Online (Sandbox Code Playgroud)
任何指针赞赏.