<p>This is a <a href="https://github.com/craftcms/cms/issues/1667" rel="nofollow noreferrer">known issue</a> – automatic cache busting currently doesn’t work when the <code>descendantOf</code> param is set to an actual element.</p>

<p>Unfortunately there’s no easy fix on Craft’s end, without a pretty drastic change to how cache busting works. </p>

<p>As a workaround, you can change your <code>descendantOf</code> param value to <code>currentPage.id</code> rather than just <code>currentPage</code>.</p>

CC BY-SA 3.0
2017-06-10T14:23:39.833Z
Thank you Brandon. I'm glad this is a known issue. However, using `entry.id` does not work for me either running version 2.6.2982. Any other workaround suggestions?
Katrin
CC BY-SA 3.0
2017-06-10T16:10:12.613Z
I added my workaround solution as an answer. If you/anyone knows of a more efficient/elegant way, do let me know :)
Katrin
CC BY-SA 3.0
2017-07-03T13:49:38.673Z
This also seems to apply when using entry.descendants or entry.getDescendants()?
Tom De Smet
CC BY-SA 3.0
2017-07-03T13:58:40.960Z
And when using children()?
Tom De Smet
CC BY-SA 3.0
2017-07-04T13:38:52.317Z
@TomDeSmet same
Brandon Kelly
CC BY-SA 3.0
2017-06-10T12:55:51.957Z
2017-06-10T12:55:51.957Z
Brandon Kelly
<p>Since using <code>descendantOf(currentPage.id)</code>, as Brandon suggested, didn't work, I have come up with this workaround solution:</p>

<pre><code>{% set currentPageID = entry.id %}

{% set entries = craft.entries.type('course') %}

{# only display entries that have currentPage as an ancestor #}
{% for entry in entries if currentPageID in entry.getAncestors().ids() %}
  {% include '_includes/_listing-item-course' with { featured : true } %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2017-06-10T16:23:33.440Z
2017-06-10T16:23:33.440Z
Katrin
<p>I found a better solution. I'm using the <a href="https://github.com/mmikkel/CacheFlag-Craft" rel="nofollow noreferrer">CacheFlag</a> plugin which solves this problem. And it's very easy to add to existing code.</p>

CC BY-SA 3.0
2017-07-03T13:49:21.837Z
2017-07-04T12:09:16.180Z
2017-07-04T12:09:16.180Z
Tom De Smet
<p>I am running into an odd issue where creating new child entries does not bust the cache of the parent page(s) that lists them.</p>

<p>This is the structure I am working with:
<a href="https://i.sstatic.net/5EBy1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/5EBy1.png" alt="enter image description here"></a></p>

<p>I am displaying the <code>Course</code> entries on the <code>Course Landing Pages</code> like so:</p>

<pre><code>{% cache using key craft.request.path %}

  {% set currentPage = craft.entries.id(entry.id).first() %}

  {% set entries = craft.entries({
    type: 'course',
    descendantOf: currentPage,
    with: [
      ['courseThumbnail', {
        withTransforms: [
          { mode: 'crop', width: 800, height: 800, position: 'center-center', format: 'jpg' }
        ]
      }]
    ]
  }) %}

  {% for entry in entries %}
      {% include '_includes/_listing-item-course' with { featured : true } %}
  {% endfor %}

{% endcache %}
</code></pre>

<p>When I publish a new <code>Course</code> entry, the cache for the parent page(s) is not busted and the new entry will not show unless I move/drag into a new position. This seems to clear the cache and the new entry shows on the parent page(s).<a href="https://i.sstatic.net/99PFY.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/99PFY.png" alt="enter image description here"></a></p>

<p>If I change the <code>craft.entries</code> call to <strong>not include</strong> the <code>descendantOf</code> part, so it looks like this:</p>

<pre><code> {% set entries = craft.entries({
    type: 'course',
    with: [
      ['courseThumbnail', {
        withTransforms: [
          { mode: 'crop', width: 800, height: 800, position: 'center-center', format: 'jpg' }
        ]
      }]
    ]
  }) %}
</code></pre>

<p>Then newly added <code>Course</code> entries will show up straight away on all the <code>Course Landing Pages</code>.</p>

<p>Why is that?</p>

CC BY-SA 3.0
2017-06-10T12:46:28.773Z
There is definitely something going on with the `descendantOf` parameter. If I set entries like this `{% set entries = craft.entries.type('course') %}`, new ones show up straight away when published. The moment I change it to this `{% set entries = craft.entries.type('course').descendantOf(entry) %}`, they won't show up unless I manually clear the cache or move the new entry’s position in the structure tree. Very odd.
Katrin
<structure><cache><children>
Newly added child entries not showing on listing/parent page straight away
# Newly added child entries not showing on listing/parent page straight away

(Asked by: username_0 on 2017-06-08)

I am running into an odd issue where creating new child entries does not bust the cache of the parent page(s) that lists them.
This is the structure I am working with:

I am displaying the Course entries on the Course Landing Pages like so:
{% cache using key craft.request.path %}

  {% set currentPage = craft.entries.id(entry.id).first() %}

  {% set entries = craft.entries({
    type: 'course',
    descendantOf: currentPage,
    with: [
      ['courseThumbnail', {
        withTransforms: [
          { mode: 'crop', width: 800, height: 800, position: 'center-center', format: 'jpg' }
        ]
      }]
    ]
  }) %}

  {% for entry in entries %}
      {% include '_includes/_listing-item-course' with { featured : true } %}
  {% endfor %}

{% endcache %}

When I publish a new Course entry, the cache for the parent page(s) is not busted and the new entry will not show unless I move/drag into a new position. This seems to clear the cache and the new entry shows on the parent page(s).
If I change the craft.entries call to not include the descendantOf part, so it looks like this:
 {% set entries = craft.entries({
    type: 'course',
    with: [
      ['courseThumbnail', {
        withTransforms: [
          { mode: 'crop', width: 800, height: 800, position: 'center-center', format: 'jpg' }
        ]
      }]
    ]
  }) %}

Then newly added Course entries will show up straight away on all the Course Landing Pages.
Why is that?

**Tags:** structure, cache, children
> **Comments:**
> **username_0**: There is definitely something going on with the `descendantOf` parameter. If I set entries like this `{% set entries = craft.entries.type('course') %}`, new ones show up straight away when published. The moment I change it to this `{% set entries = craft.entries.type('course').descendantOf(entry) %}`, they won't show up unless I manually clear the cache or move the new entry’s position in the structure tree. Very odd.  

---

## 3 answers

### Answer by username_1 on 2017-06-10. Score: 2 | Accepted answer

This is a [known issue](https://github.com/craftcms/cms/issues/1667) – automatic cache busting currently doesn’t work when the `descendantOf` param is set to an actual element.

Unfortunately there’s no easy fix on Craft’s end, without a pretty drastic change to how cache busting works.

As a workaround, you can change your `descendantOf` param value to `currentPage.id` rather than just `currentPage`.

> **Comments:**
> **username_0**: Thank you Brandon. I'm glad this is a known issue. However, using `entry.id` does not work for me either running version 2.6.2982. Any other workaround suggestions?  
> **username_0**: I added my workaround solution as an answer. If you/anyone knows of a more efficient/elegant way, do let me know :)  
> **username_2**: This also seems to apply when using entry.descendants or entry.getDescendants()?  
> **username_2**: And when using children()?  
> **username_1**: @TomDeSmet same  

---

### Answer by username_0 on 2017-06-10. Score: 1

Since using descendantOf(currentPage.id), as Brandon suggested, didn't work, I have come up with this workaround solution:
{% set currentPageID = entry.id %}

{% set entries = craft.entries.type('course') %}

{# only display entries that have currentPage as an ancestor #}
{% for entry in entries if currentPageID in entry.getAncestors().ids() %}
  {% include '_includes/_listing-item-course' with { featured : true } %}
{% endfor %}


---

### Answer by username_2 on 2017-07-03. Score: 1

I found a better solution. I'm using the [CacheFlag](https://github.com/mmikkel/CacheFlag-Craft) plugin which solves this problem. And it's very easy to add to existing code.


---

