Skip to content
  • About
    • What is Symfony?
    • Community
    • News
    • Contributing
    • Support
  • Documentation
    • Symfony Docs
    • Symfony Book
    • Screencasts
    • Symfony Bundles
    • Symfony Cloud
    • Training
  • Services
    • Platform.sh for Symfony Best platform to deploy Symfony apps
    • SymfonyInsight Automatic quality checks for your apps
    • Symfony Certification Prove your knowledge and boost your career
    • SensioLabs Professional services to help you with Symfony
    • Blackfire Profile and monitor performance of your apps
  • Other
  • Blog
  • Download
sponsored by
  1. Home
  2. Documentation
  3. Bundles
  4. LiipImagineBundle
  5. Asset Versioning

Asset Versioning

Edit this page

You can configure Symfony to append an asset version to the asset URLs. This is used to bust the cache after changes if you make clients cache assets for a long time.

If you use the Twig asset function to resolve an image file name relative to the public web folder and then put the result into imagine_filter, the query string would normally be considered part of the file name, making it so that the file can not be found.

Since LiipImagineBundle version 2.7, we integrate with the configuration setting for framework.assets.version. It strips the version from the file name and appends it to the resulting image URL so that the file is found and cache busting is used.

Since LiipImagineBundle version 2.13, we integrate with the configuration setting for framework.assets.json_manifest_path. The manifest file is used to lookup the location of the actual file, and append the versioning string to the resulting image URL so that cache busting is used.

Cache Busting

If you allow clients to cache your images, it can make sense to use asset versioning to bust the cache of your images. This can help for example after you changed the settings of a filter set.

If you use framework.assets.version, change the asset version in that case. If you use framework.assets.json_manifest_path, then rebuild the manifest in your asset pipeline. Note that your versioning string might be calculated using a content hash. Changing a filter setting in these cases will not bust the previous cache. Either rename your filter in that case or use a different versioning strategy within your asset pipeline that ensures a new hash for each build. If you do not use Symfony asset versioning, set the liip_imagine.twig.assets_version parameter. Note that you still need to clear/refresh the cached images to have them updated, the asset version is only relevant for HTTP caches but not for the LiipImagineBundle cache.

This approach works well for changed filter sets, but not for changes to individual images. For those, the best approach is to have a versioning in the file name or using the CacheResolveEvent to change the URL of the image.

Troubleshooting

If the version query is not handled correctly, check the logs during container building. If you use a custom asset versioning, you can configure the liip_imagine.twig.assets_version parameter with the version string to look for.

To completely disable asset version handling by LiipImagineBundle, you can set liip_imagine.twig.assets_version to false. But be aware that if you configured Symfony to append an asset version, you now won't be able to use the asset Twig function with the imagine_filter.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.
TOC
    Version
    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Peruse our complete Symfony & PHP solutions catalog for your web development needs.

    Save your teams and projects before they sink

    Save your teams and projects before they sink

    Version:

    Table of Contents

    • Cache Busting
    • Troubleshooting

    Symfony footer

    Avatar of Radoslaw Kowalewski, a Symfony contributor

    Thanks Radoslaw Kowalewski for being a Symfony contributor

    1 commit • 46 lines changed

    View all contributors that help us make Symfony

    Become a Symfony contributor

    Be an active part of the community and contribute ideas, code and bug fixes. Both experts and newcomers are welcome.

    Learn how to contribute

    Symfony™ is a trademark of Symfony SAS. All rights reserved.

    • What is Symfony?

      • What is Symfony?
      • Symfony at a Glance
      • Symfony Components
      • Symfony Releases
      • Security Policy
      • Logo & Screenshots
      • Trademark & Licenses
      • symfony1 Legacy
    • Learn Symfony

      • Symfony Docs
      • Symfony Book
      • Reference
      • Bundles
      • Best Practices
      • Training
      • eLearning Platform
      • Certification
    • Screencasts

      • Learn Symfony
      • Learn PHP
      • Learn JavaScript
      • Learn Drupal
      • Learn RESTful APIs
    • Community

      • Symfony Community
      • SymfonyConnect
      • Events & Meetups
      • Projects using Symfony
      • Contributors
      • Symfony Jobs
      • Backers
      • Code of Conduct
      • Downloads Stats
      • Support
    • Blog

      • All Blog Posts
      • A Week of Symfony
      • Case Studies
      • Cloud
      • Community
      • Conferences
      • Diversity
      • Living on the edge
      • Releases
      • Security Advisories
      • Symfony Insight
      • Twig
      • SensioLabs Blog
    • Services

      • SensioLabs services
      • Train developers
      • Manage your project quality
      • Improve your project performance
      • Host Symfony projects

      Powered by

    Follow Symfony