When aggregating CSS/JavaScript files using performance page in Drupal 8, drush cc css-js doesn't work, and I've to clear/rebuild all cache.

Is this a bug or the normal behavior?

How do I properly clear/rebuild only the JavaScript/CSS cache?

I want that the filenames change too, so that the browser resets its cache too.

  • 1
    You can disable aggregation in the settings.local.php file. – Eyal Jul 1 '16 at 8:47
  • but i want to keep aggregation enable :) – Cawet Jul 2 '16 at 9:52

You can run drush ev command to clear css-js cache, check example below:

drush ev '\Drupal::service("asset.css.collection_optimizer")->deleteAll(); \Drupal::service("asset.js.collection_optimizer")->deleteAll(); _drupal_flush_css_js();'

Above sample is taken from here.

  • This seem good, but i can't test it until monday, i'll accept your answer at this time :) – Cawet Jul 2 '16 at 9:55
  • ok i tested right know. I forgot to say it but i want that the file name change too , otherwith the brother don't reset his cache either. This command reset cache, but keep the same file name :/ – Cawet Jul 4 '16 at 13:56
  • sorry i fact it's not reset aggregate file neither . it seam to do the same as drush cc css-js – Cawet Jul 7 '16 at 10:12
  • This no longer seems valid. I used only de css part: drush ev '\Drupal::service("asset.css.collection_optimizer")->deleteAll(); _drupal_flush_css_js();' It did not clear the css cache and I needed to use drush cr again. – ñull Aug 16 '19 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.