設定靜態檔案的快取
您媒體和靜態檔案的快取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