0

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 %}

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

If anyone has any ideas I'd be grateful!

2
  • Circumstantial answer doesn't necessarily solve this question for everyone. Dec 5, 2015 at 22:44
  • 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
    Dec 11, 2015 at 9:34

1 Answer 1

3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.