Cached template content not invalidating My understanding of the {% cache %} tag is that if the content between it changes, the cache is invalidated and you see the new content.

I'm having an issue where a new entry is created in section, but it doesn't show up on the front-end unless I manually clear the cache in the control panel.

The content is pulled in via a loop such as:

{%  for entry in craft.entries.section( "news" ).limit(3) %}


Am I not understanding how this tag works or is something going wrong?

Edit: Here is the full code block wrapped by cache tags

{% cache %}
{%  for entry in craft.entries.section( item.nameId ).limit(3) %}
    &lt;div class="cardRow_column-carousel"&gt;
        &lt;a href="{{ entry.url }}" class="card" &gt;
            &lt;div class="card_imageHolder"&gt;
                &lt;img class="card_image" src="{{ entry.tileImage.first().getUrl(cardCrop) }}"&gt;
            &lt;/div&gt;
            &lt;div class="card_content"&gt;
                &lt;h4 class="card_content_heading"&gt;{{ entry.title }}&lt;/h4&gt;
                &lt;div class="card_content_icon"&gt;
                    {% if item.type == "video" %}
                        {% set iconType = "icon-video" %}
                    {% elseif item.type == "game" %}
                        {% set iconType = "icon-games" %}
                    {% elseif item.type == "image" or item.type == "imageGallery" %}
                        {% set iconType = "icon-image" %}
                    {% else %}
                        {% set iconType = "icon-paper" %}
                    {% endif %}
                    &lt;i class="{{ iconType }} card_content_icon-category"&gt;&lt;/i&gt;
                    &lt;i class="icon-arrow-right card_content_icon_arrow"&gt;&lt;/i&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/a&gt;
    &lt;/div&gt;
{% endfor %}
{% endcache %}


The strange thing that I'm noticing is if I add an entry it never shows up, but if I delete one it does get cleared out. And deleting an entry then causes the new one to show up.

UPDATE: Craft support determined there was a bug and plans to fix it in the next version. Current version is Craft 2.1 build 2563.
When new elements are created, there’s no way for Craft to immediately know which template caches should be cleared. That’s where the Delete Stale Template Caches task comes in. It loops through all of your caches that included element queries, re-runs the queries, and checks to see if the new element is now included in the results.

There are two things to be aware of, though:


Your element query must happen inside the {% cache %} tag pair.

bad:

{% set entries = craft.entries.section('news').limit(3) %}
{% cache %}
    {% for entry in entries %}
        ...
    {% endfor %}
{% endcache %}

good:

{% cache %}
    {% set entries = craft.entries.section('news').limit(3) %}
    {% for entry in entries %}
        ...
    {% endfor %}
{% endcache %}

The cache querying is not immediate. After saving the entry you will see a little progress bar in the CP header. You need to wait until that has completed before your caches will be cleared.