<p>I realise this is probably a duplicate of the other questions just like it but I thought I'd raise it here before filing a bug with P&amp;T. </p>

<p>Basically, when a new entry is added to a section, the template cache isn't invalidating. Here is the template in question, is there anything in the code that would cause this? </p>

<pre><code>    {% extends "_layouts/two-col" %}

    {% block main %}

        {% cache unless not craft.config.cache %}

        {{entry.body}} 

        {% set cutoffDate = now|date_modify('- ' ~ '1' ~ ' days') %}
        {% set events = craft.entries.section('whatsOn').order('dateStart') %}

        {% set eventIds = [] %}
        {% for event in events if (event.dateEnd ? event.dateEnd : event.dateStart) &gt;= cutoffDate %}
          {% set eventIds = eventIds|merge([event.id]) %}
        {% endfor %}

        {% set allEvents = craft.entries.id(eventIds).fixedOrder('true') %}

        {% paginate allEvents.limit(12) as events %}

        &lt;ul class="list list--articles"&gt;

            {% for event in events %}

                &lt;li class="item" itemscope itemtype="http://schema.org/Event"&gt;

                    &lt;header class="item__header"&gt;

                        &lt;div class="item__meta"&gt;

                            &lt;time itemprop="startDate" content="{{event.dateStart}}" datetime="{{event.dateStart}}"&gt;{{event.dateStart|date("jS F Y")}}&lt;/time&gt;

                            {% if event.dateEnd|length %}
                                — &lt;time itemprop="endDate" content="{{event.dateStart}}" datetime="{{event.dateStart}}"&gt;{{event.dateEnd|date("jS F Y")}}&lt;/time&gt;
                            {% endif %}

                        &lt;/div&gt;

                        &lt;h3 class="item__title h4" itemprop="name"&gt;&lt;a href="{{ event.url }}" class=""&gt;{{ event.title }}&lt;/a&gt;&lt;/h3&gt;

                        &lt;div class="item__type"&gt;
                            &lt;span class="tag tag--{{event.eventType|slugify}}"&gt;{{event.eventType}}&lt;/span&gt;
                            &lt;span itemprop="location" itemscope itemtype="http://schema.org/Place"&gt; {{event.location}}&lt;/span&gt;
                        &lt;/div&gt;

                    &lt;/header&gt;

                    &lt;div class="item__description"&gt;
                        &lt;a href="{{ event.url }}"&gt;Find out more&lt;/a&gt;
                    &lt;/div&gt;

                &lt;/li&gt;

            {% endfor %}

        &lt;/ul&gt;


        {% if paginate.totalPages &gt; 1 %}

            &lt;nav class="nav nav--pagination"&gt;

                &lt;ul class="nav__list"&gt;

                {# &lt;a href="{{ paginate.firstUrl }}"&gt;First Page&lt;/a&gt; #}
            {# {% if paginate.prevUrl %}&lt;a href="{{ paginate.prevUrl }}"&gt;Previous Page&lt;/a&gt;{% endif %} #}

            {% for page, url in paginate.getPrevUrls(5) %}
              &lt;li class="nav__item"&gt;
                &lt;a href="{{ url }}" class="nav__link"&gt;{{ page }}&lt;/a&gt;
              &lt;/li&gt;
            {% endfor %}

            &lt;li class="nav__item nav__item--active"&gt;&lt;span class="nav__link"&gt;{{ paginate.currentPage }}&lt;/span&gt;&lt;/li&gt;

            {% for page, url in paginate.getNextUrls(5) %}
                &lt;li class="nav__item"&gt;
                    &lt;a href="{{ url }}" class="nav__link"&gt;{{ page }}&lt;/a&gt;
                &lt;/li&gt;
            {% endfor %}

           {#  {% if paginate.nextUrl %}&lt;a href="{{ paginate.nextUrl }}"&gt;Next Page&lt;/a&gt;{% endif %}
            &lt;a href="{{ paginate.lastUrl }}"&gt;Last Page&lt;/a&gt; #}

                &lt;/ul&gt;

            &lt;/nav&gt;

        {% endif %}

        {% endpaginate %}

        {% endcache %}  

    {% endblock %}

    {% block sidebar %}

        {% include '_partials/newsletter-signup' with { grid:'false' } %}

        {% include '_partials/social' %}

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

<p>If this all looks normal, I guess it is a bug with Craft?</p>

CC BY-SA 3.0
2015-02-20T02:18:16.410Z
Looks like this is doomed to linger unless the problem magically fixes itself. I've had a similar issue with rather meaty sub-templates, but that doesn't seem relevant here. Would you mind adding your Craft version and clarifying what environment(s) are pertinent here, if only for posterity?
Matt Stein
CC BY-SA 3.0
2015-02-27T09:24:57.107Z
It appears this was fixed in a recent Craft update :)
hamishtaplin
CC BY-SA 3.0
2015-03-03T12:02:25.087Z
I'm actually still experiencing problems with this so not sure if it was indeed fixed.
hamishtaplin
CC BY-SA 3.0
2015-03-31T03:07:55.307Z
Can everyone confirm that this happens when using the `{% cache %}` tag in combination with the `{% paginate %}` tag and when creating a new entry?
Brad Bell
CC BY-SA 3.0
2015-02-05T11:45:39.447Z
Any updates on this issue, harmish?
carlcs
CC BY-SA 3.0
2015-02-09T13:53:28.690Z
Kind of. P&T looked in to it but were unable to re-produce the problem reliably so it's not something that's going to be fixed in any sort of time-frame, as far as I can tell.
hamishtaplin
<cache>
Cache not invalidating when new entry is created
# Cache not invalidating when new entry is created

(Asked by: username_0 on 2015-01-19)

I realise this is probably a duplicate of the other questions just like it but I thought I'd raise it here before filing a bug with P&T. 
Basically, when a new entry is added to a section, the template cache isn't invalidating. Here is the template in question, is there anything in the code that would cause this? 
    {% extends "_layouts/two-col" %}

    {% block main %}

        {% cache unless not craft.config.cache %}

        {{entry.body}} 

        {% set cutoffDate = now|date_modify('- ' ~ '1' ~ ' days') %}
        {% set events = craft.entries.section('whatsOn').order('dateStart') %}

        {% set eventIds = [] %}
        {% for event in events if (event.dateEnd ? event.dateEnd : event.dateStart) >= cutoffDate %}
          {% set eventIds = eventIds|merge([event.id]) %}
        {% endfor %}

        {% set allEvents = craft.entries.id(eventIds).fixedOrder('true') %}

        {% paginate allEvents.limit(12) as events %}

        

            {% for event in events %}

                

                    

                        

                            {{event.dateStart|date("jS F Y")}}

                            {% if event.dateEnd|length %}
                                — {{event.dateEnd|date("jS F Y")}}
                            {% endif %}

                        

                        {{ event.title }}

                        
                            {{event.eventType}}
                             {{event.location}}
                        

                    

                    
                        Find out more
                    

                

            {% endfor %}

        


        {% if paginate.totalPages > 1 %}

            

                

                {# First Page #}
            {# {% if paginate.prevUrl %}Previous Page{% endif %} #}

            {% for page, url in paginate.getPrevUrls(5) %}
              
                {{ page }}
              
            {% endfor %}

            {{ paginate.currentPage }}

            {% for page, url in paginate.getNextUrls(5) %}
                
                    {{ page }}
                
            {% endfor %}

           {#  {% if paginate.nextUrl %}Next Page{% endif %}
            Last Page #}

                

            

        {% endif %}

        {% endpaginate %}

        {% endcache %}  

    {% endblock %}

    {% block sidebar %}

        {% include '_partials/newsletter-signup' with { grid:'false' } %}

        {% include '_partials/social' %}

    {% endblock %}

If this all looks normal, I guess it is a bug with Craft?

**Tags:** cache
> **Comments:**
> **username_3**: Any updates on this issue, harmish?  
> **username_0**: Kind of. P&T looked in to it but were unable to re-produce the problem reliably so it's not something that's going to be fixed in any sort of time-frame, as far as I can tell.  
> **username_1**: Looks like this is doomed to linger unless the problem magically fixes itself. I've had a similar issue with rather meaty sub-templates, but that doesn't seem relevant here. Would you mind adding your Craft version and clarifying what environment(s) are pertinent here, if only for posterity?  
> **username_0**: It appears this was fixed in a recent Craft update :)  
> **username_0**: I'm actually still experiencing problems with this so not sure if it was indeed fixed.  
> **username_2**: Can everyone confirm that this happens when using the `{% cache %}` tag in combination with the `{% paginate %}` tag and when creating a new entry?  

---

## 0 answers

