Set cache for static files
The cache time-to-live (TTL) for your media and static files is set in the .magento.app.yaml configuration file using the expires key.
Before making changes to your Production environment, we highly recommend testing in your Staging environment first. You must submit a support ticket to update the configuration on these environments.
-
Specify the TTL time (in seconds) in the
websection of the.magento.app.yamlfile. You can add theexpireskey underlocationsor under"/media"and"/static".To prevent the cache from expiring, use the
expires: -1key-value pair. See the following example:1 2 3 4 5 6 7 8 9 10
# The configuration of app when it is exposed to the web. web: locations: "/media": ... expires: -1 "/static": ... expires: -1
-
Add, commit, and push your code changes.
1
git add -A && git commit -m "Set cache TTL for static files" && git push origin <branch-name>