2

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?

2 Answers 2

3

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

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

2 Comments

This is more like a solution, Thanks. I didn't know this option. The only things is it'll force the refresh for all assets...
You're right, but the performance impact on the client is not so much, as the performance impact on the server side if you have to determine the file timestamp of every file on every request.
0

You can try it, i'm not sure of the result but it can work.

php app/console assetic:dump --watch

1 Comment

This is for dumping assets on the server. The client still won't be aware of any change.

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.