<p>I fixed it - there was a stuck task preventing the stale template cache from being deleted.</p>

CC BY-SA 3.0
2015-12-05T16:29:08.013Z
2015-12-05T16:29:08.013Z
Tchick
<p>I have a problem with a pair of cache tags refusing to bust the cache when a new entry is added.  The cache works well otherwise.
This is the template code I'm using... it's fairly complex as we're using it to filter products in an ecommerce site.</p>

<pre><code>{% cache %}
  {% set products = craft.entries.section('products').relatedTo(entry).find({limit: 1000}) %}
  {% include 'shop/partials/_product_list' with { products : products } %}
{% endcache %}
</code></pre>

<p>This is the include. </p>

<pre><code>{% for product in products %}
    {% set cat_classes = '' %}

    {% for cat in product.category %}
        {% set cat_classes = cat_classes ~ ' ' ~ cat.slug %}
    {% endfor %}

    {% for cat in product.collection %}
        {% set cat_classes = cat_classes ~ ' ' ~ cat.slug %}
    {% endfor %}

    {% for range in craft.entries.find({limit: 1000, section: 'priceRange'}) %}
        {% if product.price &gt;= range.priceFrom and product.price &lt;= range.priceTo %}
            {% set cat_classes = cat_classes ~ ' ' ~ range.slug %}
        {% endif %}
    {% endfor %}

    {% for days in craft.entries.find({limit: 1000, section: 'leadInTimes'}) %}
        {% if product.leadInTime &gt;= days.leadInFromDays and product.leadInTime &lt;= days.leadInToDays %}
            {% set cat_classes = cat_classes ~ ' ' ~ days.slug %}
        {% endif %}
    {% endfor %}

    {% if product.canBePurchasedOnline %}
        {% set cat_classes = cat_classes ~ ' buy-online' %}
    {% else %}
        {% set cat_classes = cat_classes ~ ' special-order' %}
    {% endif %}

    &lt;div class="prod {{ cat_classes }}"&gt;&lt;a href="{{ product.url }}"&gt;
        &lt;picture&gt;
            ...
        &lt;/picture&gt;
        &lt;div class="pdesc"&gt;
            &lt;h3&gt;{{ product.title }}&lt;/h3&gt;
            &lt;span class="price-from"&gt;£{{ product.price }}&lt;/span&gt;
        &lt;/div&gt;
    &lt;/a&gt;&lt;/div&gt;&lt;!-- /prod --&gt;
{% endfor %}
</code></pre>

<p>If anyone has any ideas I'd be grateful!</p>

CC BY-SA 3.0
2015-12-05T22:44:56.260Z
Circumstantial answer doesn't necessarily solve this question for everyone.
RitterKnight
CC BY-SA 3.0
2015-12-11T09:34:04.003Z
RitterKnight - Well it was the stuck task that caused the issue with the cache not clearing. Once the stuck task was cleared, the issue was resolved. How does that not necessarily solve the problem?  Granted, there may be other reasons for a cache not clearing I suppose. It may help people to know that a stuck task can cause the issue seen here though - hence why I posted the answer.
Tchick
<cache>
Cache won't bust on new entry
# Cache won't bust on new entry

(Asked by: username_0 on 2015-12-05)

I have a problem with a pair of cache tags refusing to bust the cache when a new entry is added.  The cache works well otherwise.
This is the template code I'm using... it's fairly complex as we're using it to filter products in an ecommerce site.
{% cache %}
  {% set products = craft.entries.section('products').relatedTo(entry).find({limit: 1000}) %}
  {% include 'shop/partials/_product_list' with { products : products } %}
{% endcache %}

This is the include. 
{% for product in products %}
    {% set cat_classes = '' %}

    {% for cat in product.category %}
        {% set cat_classes = cat_classes ~ ' ' ~ cat.slug %}
    {% endfor %}

    {% for cat in product.collection %}
        {% set cat_classes = cat_classes ~ ' ' ~ cat.slug %}
    {% endfor %}

    {% for range in craft.entries.find({limit: 1000, section: 'priceRange'}) %}
        {% if product.price >= range.priceFrom and product.price <= range.priceTo %}
            {% set cat_classes = cat_classes ~ ' ' ~ range.slug %}
        {% endif %}
    {% endfor %}

    {% for days in craft.entries.find({limit: 1000, section: 'leadInTimes'}) %}
        {% if product.leadInTime >= days.leadInFromDays and product.leadInTime <= days.leadInToDays %}
            {% set cat_classes = cat_classes ~ ' ' ~ days.slug %}
        {% endif %}
    {% endfor %}

    {% if product.canBePurchasedOnline %}
        {% set cat_classes = cat_classes ~ ' buy-online' %}
    {% else %}
        {% set cat_classes = cat_classes ~ ' special-order' %}
    {% endif %}

    
        
            ...
        
        
            {{ product.title }}
            £{{ product.price }}
        
    
{% endfor %}

If anyone has any ideas I'd be grateful!

**Tags:** cache

> **Comments:**
> **username_1**: Circumstantial answer doesn't necessarily solve this question for everyone.  
> **username_0**: username_1 - Well it was the stuck task that caused the issue with the cache not clearing. Once the stuck task was cleared, the issue was resolved. How does that not necessarily solve the problem?  Granted, there may be other reasons for a cache not clearing I suppose. It may help people to know that a stuck task can cause the issue seen here though - hence why I posted the answer.  

---

## 1 answers

### Answer by username_0 on 2015-12-05. Score: 3

I fixed it - there was a stuck task preventing the stale template cache from being deleted.


---

