Set cache for static files

Last update: 2023-06-30
  • Created for:
  • Admin

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 to update 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:

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

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

On this page