python – Google App Engine:如何在“静态”文件上禁用缓存,或使缓存智能

我在本地使用应用程序引擎,有时JS文件正在页面刷新之间被缓存,并且它驱使我疯狂,因为我不知道我正在尝试编写的JavaScript代码是否有错误,或者如果缓存正在起作用.

如何完全禁用* .js文件的缓存?或者也许问题是,如何让它变得聪明,就像最后修改日期一样.

谢谢!

最新情况:
所以事实证明Chrome Dev(对于Mac至少)有缓存问题,回到Chrome Beta修复这一切.谢谢,答案仍然有帮助

最佳答案
基于the docs,您可以指定应用范围的缓存到期时间:

Unless told otherwise, web browsers retain files they load from a website for a limited period of time. You can define a global default cache period for all static file handlers for an application by including the default_expiration element, a top-level element. You can also configure a cache duration for specific static file handler. (Script handlers can set cache durations by returning the appropriate HTTP headers to the browser.)

default_expiration

The length of time a static file served by a static file handler ought to be cached in the user’s browser, if the handler does not specify its own expiration. The value is a string of numbers and units, separated by spaces, where units can be d for days, h for hours, m for minutes, and s for seconds. For example, “4d 5h” sets cache expiration to 4 days and 5 hours after the file is first loaded by the browser.

default_expiration is optional. If omitted, the default behavior is to allow the browser to determine its own cache duration.

…并且如果要在逐个目录的基础上指定到期时间:

expiration

The length of time a static file served by this handler ought to be cached in the user’s browser. The value is a string of numbers and units, separated by spaces, where units can be d for days, h for hours, m for minutes, and s for seconds. For example, “4d 5h” sets cache expiration to 4 days and 5 hours after the file is first loaded by the browser.

尝试将它们设置为0d0h或1s,并查看是否完全禁用缓存.

转载注明原文:python – Google App Engine:如何在“静态”文件上禁用缓存,或使缓存智能 - 代码日志