umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.45k stars 2.68k forks source link

Macro caching does not reset when new content is published in Umbraco #12849

Closed mzhang-asi closed 1 year ago

mzhang-asi commented 2 years ago

Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9

8.18.4

Bug summary

  1. A Macro "latestArticles" is created and expire period is set to 3600 seconds.
  2. A new article (NOT "latestArticles" macro) is published during this 3600 seconds.
  3. "latestArticles" macro is not refreshed on page before 3600 seconds expires.
  4. "latestArticles" macro is only refreshed after 3600 seconds

In umbraco 7.15.7, "latestArticles" macro is always refreshed anytime after a new article is published.

Specifics

No response

Steps to reproduce

  1. A Macro "latestArticles" is created and expire period is set to 3600 seconds.
  2. A new article (NOT "latestArticles" macro) is published during this 3600 seconds.
  3. "latestArticles" macro is not refreshed on page before 3600 seconds expires.
  4. "latestArticles" macro is only refreshed after 3600 seconds

Expected result / actual result

"latestArticles" macro should be refreshed anytime after a new article is published, even before 3600 seconds expires.

github-actions[bot] commented 2 years ago

Hi there @mzhang-asi!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

kjac commented 1 year ago

Hi @mzhang-asi,

Thank you for this. And apologies for not getting back to you sooner.

I am not sure I share your view on how macro caching should work. Indeed I am quite sure the caching has never been invalidated automatically by publishing events or other events. This would directly contradict the functionality of caching in general, although I understand how it could come in handy for your particular use case.

The V7 (and V8) docs also have no mention of macro caching being invalidated by content publishing. See https://our.umbraco.com/Documentation/Reference/Templating/Macros/index-v7#caching-macro-output

Your V7 macro might have been configured for "Cache by Page", in which case it could have appeared be invalidated at page publish time. Or you might have had some custom event handling code explicitly flushing the macro cache at page publish time?

In either case, the macro caching is not supposed to be flushed whenever content is published, so I'm closing this issue now. I understand this is probably not the answer you were looking for, and I do hope you will find another way around your needs for macro cache flushing.