What are the Slack Archives?

It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.

Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..

Hi together. I made some changes to our frontend and after that I was running "npm run yves:producti

U018C9YQDU0
U018C9YQDU0 Posts: 8 πŸ§‘πŸ»β€πŸš€ - Cadet

Hi together. I made some changes to our frontend and after that I was running "npm run yves:production". Now I have the problem that many users have problems with the site. Since the problem can always be solved by deleting their browser cache, I am wondering if there is a method to invalidate client caches on the server side. What is the best practice here?

I am no web developer and therefore I am a bit clueless here. I already tried the following

β€’ restarting fpm
β€’ disabling opcache
β€’ console cache:empty-all
β€’ console twig:cache:warmer
β€’ restarting nginx

Comments

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice
    edited September 2020

    Hi Christian, I believe this PR https://github.com/spryker-shop/suite/pull/548 was aimed to solve exactly this issue.
    AFAIK specifically "path": "assets/%SPRYKER_BUILD_HASH%/%theme%", change.

  • U018C9YQDU0
    U018C9YQDU0 Posts: 8 πŸ§‘πŸ»β€πŸš€ - Cadet

    Hi @valerii.trots, thanks for your fast reply. I tried to configure path as you suggested (adding "%SPRYKER_BUILD_HASH%"). But after running npm run yves:production, the assets are placed to assets/%SPRYKER_BUILD_HASH%/...

    The variable is not resolved.

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    Do you run it locally?
    Docker? What is the tag for docker-sdk?

  • U018C9YQDU0
    U018C9YQDU0 Posts: 8 πŸ§‘πŸ»β€πŸš€ - Cadet

    I have tested it with docker. I am not sure what you mean by "tag". I am using the deploy.dev.yml (docker/sdk boot). And I have tested the configuration by runinng "npm run yves:production" with "docker/sdk cli" after launching everything with "docker/sdk reset"

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    Tag is the git's terminology. Are you on the latest master of spryker/docker-sdk or you cloned specific release version\tag?

  • U018C9YQDU0
    U018C9YQDU0 Posts: 8 πŸ§‘πŸ»β€πŸš€ - Cadet

    ah ok. I do not know since I added the sdk not as a git submodule to the project. But I will repeat the test with the latest docker/sdk version

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice
    edited September 2020

    If you are going to experiment anyway, could you please try to clone and install latest demoshop and latest spryker/docker-sdk and try it there? πŸ™‚
    Basically I'm not sure what exact changes have to be done from that PR but it should have solved the problem.

  • U018C9YQDU0
    U018C9YQDU0 Posts: 8 πŸ§‘πŸ»β€πŸš€ - Cadet

    Here the results of my tests with the latest b2b demo shop version and the latest sdk version:

    After running "npm run yves:production" with "docker/sdk cli" all assets are put to "assets/current/default/DE/..."

    The variable SPRYKER_BUILD_HASH always seems to be set to "current". With regard to with the outdated browser cache this would not help since the path is not changed and therefore the client would use its outdated cache instead of loading the new files.

    Or do I understand this the wrong way?

  • Valerii Trots
    Valerii Trots SRE @ Spryker Sprykee Posts: 1,654 ✨ - Novice

    I would ask @UN6T8SEM7 here.

  • Stanislav Matveyev
    Stanislav Matveyev Sprykee Posts: 211 πŸ§‘πŸ»β€πŸš€ - Cadet

    do you have this line in the config?

    $config[ShopUiConstants::YVES_ASSETS_URL_PATTERN] = '/assets/' . (getenv('SPRYKER_BUILD_HASH') ?: 'current') . '/%theme%/';
    

    if yes,

    try to set
    export SPRYKER_BUILD_HASH=any-string-for-assets
    then run npm run yves:production

    in Yves check that folder for .js/.css is changed to any-string-for-assets

    But I don't know how to set it for all docker services

  • giovanni.piemontese
    giovanni.piemontese Spryker Solution Partner Posts: 871 πŸ§‘πŸ»β€πŸš€ - Cadet

    This Problem is known and only solution now is to extend the publicPath Twig function and add as suffix the filemtime for the requested css or js.. In this case u are sure that the browser cache is automatically invalidate when the filemtime changed after a new npm run yves:production

    Of course, and i am sure, that exists some other better solution, but at the moment is the unique fast solution that i found last year....