Google App Engine: How to disable cache on 'static' files, or make cache smart

后端 未结 2 1627
春和景丽
春和景丽 2020-12-31 08:54

I\'m using the app engine locally, and sometimes the JS files are being cached between page refreshes, and it drives me crazy because I don\'t know if there\'s a bug in the

2条回答
  •  时光说笑
    2020-12-31 09:27

    Based on the docs, you can specify an app-wide cache expiration duration:

    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.

    ...and if you want to specify the expiration on a directory-by-directory basis:

    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.

    Try setting them to 0d0h or 1s and see if it disables caching entirely.

提交回复
热议问题