2

In production, when minifying the css (php app/console assetic:dump), the file is re-created but the name don't change.

Thus users browser keep in cache the old version. A workaround is to add after the css name a parameter like ?v=12 to force that cache, but is there another solution? How Symfony generate the css filename? Name that file with its md5 would solve the problem, because when the file change its name would also change.

{% stylesheets filter='cssrewrite,?yui_css'
        'bundles/app/css/style.css'
    %}
        <link rel="stylesheet" type="text/css" media="screen" href="{{ asset_url }}" />
    {% endstylesheets %}

In my source the filename is still the same event after a change in the css :

<link rel="stylesheet" type="text/css" media="screen" href="/css/b3ba425.css" />

1 Answer 1

1

Unfortunately it seems there is no better way to force user's cache to refresh than adding version number. However this might be automated in nice way:

There is KachkaevAssetsVersionBundle which provides assets_version:increment task, so having this bundle all you need to do is:

Add in your config.yml

framework:
    templating:
        assets_version: %assets_version%

Then in your parameters.yml.dist / parameters.yml:

parameters:
    assets_version: v1

The task assets_version:increment will increment v1 value for you.

I would also recommend to add this command to your composer's post install or post update scripts

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.