I want to add ?v=20170721 after css file


I tried to set "yes" in sign static files but this is not what I want

How to force the customers update their CSS in client side?

1 Answer 1


I found out where to control the header content.

I create a preference and override the function renderAssetGroup() in Magento\Framework\View\Page\Config\Renderer

protected function renderAssetGroup(\Magento\Framework\View\Asset\PropertyGroup $group)
    $groupAssets = $this->processMerge($group->getAll(), $group);

    $attributes = $this->getGroupAttributes($group);
    $attributes = $this->addDefaultAttributes(

    $groupTemplate = $this->getAssetTemplate(

    $version = '20170809';
    $getPath = $this->renderAssetHtml($groupTemplate, $groupAssets);
    if(strpos($getPath, '.css"') !== false){
        $getPath = str_replace('.css"', '.css?v='.$version.'"', $getPath);
    if(strpos($getPath, '.js"') !== false){
        $getPath = str_replace('.js"', '.js?v='.$version.'"', $getPath);

    $groupHtml = $getPath;
    $groupHtml = $this->processIeCondition($groupHtml, $group);
    return $groupHtml;

Your Answer

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

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