Set cache for static files

The cache TTL (time-to-live) for your media and static files is set in the 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.
  1. Specify the TTL time (in seconds) in the web property of the file. You can add the expires key under locations or under "/media" and "/static".

    To prevent the cache from expiring, use the expires: -1 key-value pair. See the following example:

    code language-yaml
    # The configuration of app when it is exposed to the web.
          expires: -1
          expires: -1
  2. Add, commit, and push your code changes.

    code language-bash
    git add -A && git commit -m "Set cache TTL for static files" && git push origin <branch-name>