[僅限PaaS]{class="badge informative" title="僅適用於雲端專案(Adobe管理的PaaS基礎結構)和內部部署專案的Adobe Commerce 。"}
設定靜態檔案的快取
您媒體和靜態檔案的快取TTL (存留時間)是使用expires索引鍵在.magento.app.yaml設定檔案中設定的。
NOTE
在更新生產環境之前,請務必在中繼環境中測試變更。 提交Adobe Commerce支援票證,以取得更新這些環境設定的協助。
-
在
.magento.app.yaml檔案的web屬性中指定TTL時間(秒)。 您可以在locations底下或在"/media"與"/static"底下新增expires金鑰。若要防止快取到期,請使用
expires: -1機碼值組。 請參閱下列範例:code language-yaml # The configuration of app when it is exposed to the web. web: locations: "/media": ... expires: -1 "/static": ... expires: -1 -
新增、提交和推送您的程式碼變更。
code language-bash git add -A && git commit -m "Set cache TTL for static files" && git push origin <branch-name>
recommendation-more-help
7c2b03ac-000c-497d-aba3-2c6dc720a938