0

I'm using the ShareThis module to power my sharing links on a Drupal 7 site, but I don't think my question is specific to this module.

I want to modify the link that's shared and sharethis provides a theme_sharethis() function where I can override the output. I have mytheme_sharethis() in my template.php file where I modify the output as required. On my dev box (where I have disable caching) this works fine.

We're using Memcache and Varnish modules for pretty heavy site caching.

Quite often, when new content is created (and in some cases older content is viewed) my theme function, which changes the urls, is ignored. It gives the default share this links instead of my custom url patterns from the theme function. It does this for both logged in and logged out users.

If I clear caches multiple times, eventually it recognizes the theme function and gives the proper link. Obviously I want it to use the correct link the first time!

I suppose my question starts by asking which cache (Drupal, Memcache, Varnish) this is likely occurring in (I think I know the answer, but want to confirm). The obvious next question is how I get it to recognize my theme function every time without clearing the caches first.

  • Really broad question. But pretty obviously it's your caching. I remember a similar problem we once had with the captcha module. And eventually ended in ajaxifying parts of it to ensure the captchas were not cached. I don't know how this share module works. Maybe it already is sufficient to have the routes it uses to fetch the links excluded from caching. – leymannx Aug 15 '18 at 18:18
  • Yeah, I wrote it fairly broad intentionally. Maybe to step back I'm asking "which cache would this get 'stuck' in?' and then we could go forward trying to determine how to force that cache to clear when a particular node is created/edited... – Feature Aug 15 '18 at 18:29
  • I'm also using advanced aggregation module...that caches things so heavily, I'm starting to wonder if that's the cause of all this... – Feature Aug 16 '18 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.