I use hook_metatag_metatags_view_alter to alter the canonical metatag, it works as planned on Dev but not on prod.
I guess it has something to do with cache, but I can't figure out how to deal with it.
This is the code I use:

function mymodule_metatag_metatags_view_alter(&$output, $instance, $options) {
   if ($instance == 'specific_entity') { 
      $url_relative = token_replace('[current-page:url:relative]');
      $canonical_scheme = 'https://mycanonicaldomain.com' . $url_relative;
      $output['canonical']['#attached']['drupal_add_html_head'][0][0]['#value'] = $canonical_scheme;
  }
}

Thanks for any clues.

Comments

pedrosp created an issue. See original summary.

zuernBernhard’s picture

Do you have some kind of page cache on the production site ?

zuernBernhard’s picture

Do you have "cacheing" active for your View ?

pedrosp’s picture

I am using this hook to alter the metatag when displaying the view operation of an Entity Object (ECK entity), not a View (as for Views).

Entity Cache is activated

On admin/config/development/performance
CACHING
YES Cache pages for anonymous users
YES Cache blocks
none: Minimum cache lifetime
none: Expiration of cached pages
BANDWIDTH OPTIMIZATION
YES Compress cached pages
YES Aggregate and compress CSS files
YES Aggregate Javascript files
X AUTOLOAD
(All options disabled)

Using AdvAgg also, but there is a lot of options, please tell if relevant.

Thanks for the support.

DamienMcKenna’s picture

Is there a difference in the Metatag settings between dev and prod?

pedrosp’s picture

Status: Active » Closed (works as designed)

SOLVED
i use Features to roll-out config and variables but I missed on admin/config/search/metatags/settings :
Master Controls for all entities: Those specific ECK entities was disabled on PROD (and enabled on DEV)

I feel dumb to missed that :|
Thanks for the tip Damien.

DamienMcKenna’s picture

I'm just glad you got to the bottom of it :-)