3

I want to add ?v=20170721 after css file

http://example.com/pub/static/_cache/merged/91eeca7a8ffa88b106ef85bd3a665d93.min.css?v=20170721

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?

0

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(
        $group->getProperty(GroupedCollection::PROPERTY_CONTENT_TYPE),
        $attributes
    );

    $groupTemplate = $this->getAssetTemplate(
        $group->getProperty(GroupedCollection::PROPERTY_CONTENT_TYPE),
        $attributes
    );

    $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, privacy policy and cookie policy

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