HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How do I cache bust theme updates now?

jamesincjamesinc Sydney ✭✭

I've just upgraded from Vanilla 3.3 to 2021.012. I've been releasing tweaks to my forum's theme to fix some UI regressions, but I'm having trouble getting the changes deployed.

Up until now, this has been easy, as incrementing the version in addon.json in the theme directory cache busts all the assets for users, however now the cache querystring is no longer the version from addon.json, but the forum version, i.e. instead of custom.css?v=1.2.3 (where 1.2.3 is the version in addon.php) I now have custom.css?v=2021.012

What is the new pattern for cache busting these sorts of resources?

Best Answer

  • R_JR_J Ex-Fanboy Munich Admin
    Answer ✓

    Not sure about it and not able to test it, but you might be able to add a config setting to achieve what you need to: $Configuration['Garden']['Deployed'] = some timestamp; might work

    This class returns that APPLICATION_VERSION if no property deploymentTime exists https://github.com/vanilla/vanilla/blob/master/library/Vanilla/Web/Asset/DeploymentCacheBuster.php

    And in the bootstrap.php the cahce buster class is added to the container like that:

        ->rule(\Vanilla\Web\Asset\DeploymentCacheBuster::class)
        ->setShared(true)
        ->setConstructorArgs([
            'deploymentTime' => ContainerUtils::config('Garden.Deployed')
        ])
    

Answers

  • jamesincjamesinc Sydney ✭✭

    For anyone interested, I have worked around this for now by editing the APPLICATION_VERSION var in environment.php, I just added a suffix to make version 2021.012-20210620

    This has updated the cache querystrings on all my theme resources and solved the issue.

  • R_JR_J Ex-Fanboy Munich Admin
    Answer ✓

    Not sure about it and not able to test it, but you might be able to add a config setting to achieve what you need to: $Configuration['Garden']['Deployed'] = some timestamp; might work

    This class returns that APPLICATION_VERSION if no property deploymentTime exists https://github.com/vanilla/vanilla/blob/master/library/Vanilla/Web/Asset/DeploymentCacheBuster.php

    And in the bootstrap.php the cahce buster class is added to the container like that:

        ->rule(\Vanilla\Web\Asset\DeploymentCacheBuster::class)
        ->setShared(true)
        ->setConstructorArgs([
            'deploymentTime' => ContainerUtils::config('Garden.Deployed')
        ])
    
Sign In or Register to comment.