OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – How do I? Questions How to configure path based asset versioning

This topic contains 3 replies, has 3 voices, and was last updated by  Artem Liubeznyi 5 years, 8 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #36635

    Brad Harrison
    Participant

    Currently assets are versioned within Oro by adding the ‘version’ GET argument onto the url:

    For example on the demo site:

    /css/oro.css?version=3315ead4

    We are planning on using a web accelerator in front of our Oro instances as we wish to reduce load on the application servers. The web accelerator ideally would like to cache based on paths rather than GET arguments. So the asset path would become something like:

    /assets/3315ead4/css/oro.css

    So the formats would be:

    BEFORE: <path>?version=<version>
    AFTER: /assets/<version><path>

    We are planning on using rewrite rules to make the ‘/assets/<version>/’ path virtual. So there will be no change to how Oro manages the files but there will need to be a change to how the assets are referenced when generating HTML and loading scripts.

    The DynamicAssetVersionStrategyTest within the UIBundle seems to allude that this is possible by using a format similar to ‘%2$s/%1$s’. I understand there may be issues with how requirejs loads them due to the urlArgs callback within RequireJSBundle/Resources/views/scripts.html.twig.

    Is this kind of versioning achievable? If not, is it something that could be added to the roadmap?

    Cheers.

    Brad

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #36637

    Andrey Yatsenko
    Moderator

    The web accelerator ideally would like to cache based on paths rather than GET arguments.

    All the CDNs I know are using the path as cache id for static files as you said, but they always take into account get parameters as it’s a part of the path, so there should not be any issues.

    Can you share, what web accelerator are you going to use? so we’ll take it into account.

    #36638

    Brad Harrison
    Participant

    Thanks Andrey for your response and I apologise for the delay in responding to you.

    We are using Varnish (https://varnish-cache.org/) with a custom configuration of our own creation. Varnish can cache content with GET parameters but the reason we are looking at using paths is to simplify and standardise the configurations across all of our products (including non-Oro applications). By only looking at paths we can add a standard rule to ignore or remove any GET params. This specifically solves issues where tracking or other ‘dynamic’ parameters get injected.

    There are examples on the web on how to ‘clean’ the GET parameters (see https://stackoverflow.com/questions/29011388/varnish-how-to-cache-a-url-with-parameters-need-to-strip-multiple-parameters) so it is technically possible to get Varnish to cache versioned assets. It just means we’ll have to customise our Oro configurations.

    Can path based asset versioning be added to the roadmap?

    Cheers.

    Brad

    #36639

    Artem Liubeznyi
    Spectator

    Hi Brad,

    We can add it to our backlog but this item does not really match our immediate nor near-term priorities, so it’s hard to predict when (and if ever) it will make its way to the product. Customization appears to be the best solution for now.

Viewing 3 replies - 1 through 3 (of 3 total)

The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.

Back to top