如何在 Google 灵活引擎中设置静态文件的过期时间

How to set expiration time for static files in Google flexible engine

我有一个 app.yaml 文件,与我的 python 应用程序主文件处于同一级别。 我想在 app.yaml 中添加一个可以配置静态文件夹过期时间的处理程序。 我怎样才能在 google 灵活引擎 中做同样的事情?

handlers:
- url: /images
  static_dir: static/*
  expiration: "4d 5h"

在 flex 环境中 app.yaml file has no support for such handlers element 规范。

如果您是 serving the static files through your application,则需要查看您正在使用的框架的具体说明。

如果你是 serving the static files from Cloud Storage see Setting cache parameters:

You can control how or if your website assets are cached by configuring cache control headers. Generally, only set cache control headers for objects that are accessible to all anonymous users, which is a requirement for any object served from a Cloud Storage bucket as part of a static website.

Google Cloud Storage applies a cache control setting of 3600 seconds to objects that are accessible to all anonymous users, unless you specify explicit cache control settings. For examples, see the metadata page of gsutil, the setting object metadata page for the Google Cloud Platform Console, or headers reference pages for XML and JSON.