Im using a pretty standard method for calling for entries, but with one small caveat in that I'm setting the limit inside a variable which is passed through to an include

so my index.twig file is like so

{% include 'homepage/_latest' with {'postCount' : 9} %}

and my homepage/_latest file has the following

{% cache %}
{% set latest = craft.entries.section('blog').limit(postCount ? postCount : 12) %}

<div class="entries entries--latest">

    {% for entry in latest %}

    {% include 'blocks/_entry-item-latest' %}

    {% endfor %}


{% endcache %}

Is that variable the issue for me/ I save a post and it doesnt know up on the homepage. I had it setup to invalidate every 15 minutes, but we put out 3-4 posts a day so theres no real need to invalidate that content every 15 minutes

  • I'm pretty sure that wouldn't affect it. What happens if you remove it as a test.
    – Brad Bell
    Commented Nov 20, 2014 at 21:18

1 Answer 1


If I understand you correctly, you’d basically need it to store separate caches depending on the limit.

The way to do that would be to set a custom key on the {% cache %} tag with the using key param:

{% if postCount is not defined or not postCount %}
    {% set postCount = 12 %}
{% endif %}

{% cache using key "homepage/_latest:"~postCount %}
    {% set latest = craft.entries.section('blog').limit(postCount) %}
{% endcache %}

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.