Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Symfony 2 asset compilation to product different filenames?

I followed the guide on the very bottom of this article: http://symfony.com/doc/current/cookbook/assetic/asset_management.html

I have this code:

    {% javascripts
        ...

        output='js/dist/dist.js'
    %}
    <script src="{{ asset_url }}"></script>
    {% endjavascripts %}

Now if I run sf assetic:dump --env=prod it creates the compiled file properly. However, I would like to have it generating a random name (or timestamped) so that the client-side browser cache problem is avoided. Right now it always creates dist.js file which gets cached and when I update my code the users won't see the difference (or get errors).

Is there a way to make it like dist12345678.js?

like image 960
Tower Avatar asked Jan 18 '12 13:01

Tower


1 Answers

You have two options here: Either leave out the output file name (it will then be an autogenerated hash that changes) or use asset versions, as described in the Symfony docs: http://symfony.com/doc/current/reference/configuration/framework.html#ref-framework-assets-version

like image 168
chiborg Avatar answered Sep 19 '22 03:09

chiborg