Cms: Caches not being set/cleared properly for Global sets

Created on 23 Nov 2020  Â·  4Comments  Â·  Source: craftcms/cms

Description

Updating a Global set in the Control Panel does not cause its caches to be cleared (or set) properly.

Steps to reproduce

  1. In a template, add {% cache %}/{% endcache %} tags around the output of a global.
  2. Modified the content in the Control Panel → save.
  3. Refresh front-end.

Additional info

  • Craft version: latest
  • PHP version: 7.4
bug

Most helpful comment

Just fixed this for the next release. Going forward, whenever you access the property of an element within a {% cache %} tag (e.g globalSetHandle.fieldHandle), the element will be included as a dependency of the cache.

All 4 comments

I've been bit by this, but I didn't figure it to be a _bug_ as much as a side-effect of the new tag-based caching system in 3.5.

It only appears to happen with global sets that don't have any relational fields, which makes sense since cache tags are derived from element queries, and the global sets themselves aren't usually queried for in Twig.

It would be nice if this could work like pre-3.5, though – i.e. have Craft automatically collect the appropriate cache tags for any global sets in the context (similarly to how it collects tags for the matched element, i.e. entry).

Just fixed this for the next release. Going forward, whenever you access the property of an element within a {% cache %} tag (e.g globalSetHandle.fieldHandle), the element will be included as a dependency of the cache.

(You will need to invalidate all template caches before this change will take effect.)

Craft 3.5.16 is out now with that fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mccombs picture mccombs  Â·  3Comments

angrybrad picture angrybrad  Â·  3Comments

benface picture benface  Â·  3Comments

mattstein picture mattstein  Â·  3Comments

bitboxfw picture bitboxfw  Â·  3Comments