Search code examples
cachingsymfonyassetic

Symfony - Assets cache auto versioning


I'd like to force client's cache refresh for modified assets.

Is there already a native way to do it with asset() like

<script src="{{ asset('js/main.js')|autoversion }}"></script>

?

If not, I found this really elegant solution (based on file timestamp & url rewrite) to manage it.
Did someone already faced this question and would know how to extend asset() for example?


Solution

  • Take a look at the assets_version parameter, so every asset get a version string without doing extra things in the template