Set cache for static files
Last update: February 3, 2025
- Topics:
- Cloud
- Configuration
- Cache
- SCD
CREATED FOR:
- Admin
- Developer
The cache TTL (time-to-live) for your media and static files is set in the .magento.app.yaml
configuration file using the expires
key.
Before updating your Production environment, it is important to test changes in your Staging environment. Submit an Adobe Commerce Support ticket for help with updating the configuration on these environments.
-
Specify the TTL time (in seconds) in the
web
property of the.magento.app.yaml
file. You can add theexpires
key underlocations
or under"/media"
and"/static"
.To prevent the cache from expiring, use the
expires: -1
key-value pair. See the following example:# 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.
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