<p>You would simply not wrap it in <code>cache</code> tags. I don't think there's anything like that EE function to specifically exclude parts within the tag. Might be worth a <a href="http://feedback.buildwithcraft.com" rel="nofollow">feature request</a> though?</p>

<pre><code>{% set item = craft.shortlist.item(entry.id) %}

{% cache globally using key "product-card-" ~ entry.id ~ "-1" until entry.dateUpdated %}

    {{ entry.title }}

    ...

{% endcache %}

// EXCLUDE THIS PART FROM CACHE
{% if item.inList %}
    &lt;a class="love animating fav" href="{{ item.removeActionUrl }}" data-id="{{ entry.id }}"&gt;&lt;i class="icon icon-heart"&gt;&lt;/i&gt;&lt;/a&gt;
{% else %}
    &lt;a class="love animating" href="{{ item.addActionUrl }}" data-id="{{ entry.id }}"&gt;&lt;i class="icon icon-heart"&gt;&lt;/i&gt;&lt;/a&gt;
{% endif %}

{% cache globally using key "product-card-" ~ entry.id ~ "-2" until entry.dateUpdated %}

    ...

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

CC BY-SA 3.0
2015-04-01T17:22:03.543Z
Doesn't work. It's repeating the cached content in the 2nd part.
Johannes Lamers
CC BY-SA 3.0
2015-04-01T17:26:18.993Z
Sorry, I overlooked that you're using custom keys. These need to be unique, so you have to add unique string to the key for each caching block.
carlcs
CC BY-SA 3.0
2015-04-01T17:28:00.180Z
Ok. that's what i was thinking. But you then end up with a lots of Cached content per entry. Let say you have some more dynamic data. All the cached content gets cluttered in the DB. I've posted a feature request to escape some parts of the cache tough.
Johannes Lamers
CC BY-SA 3.0
2015-04-01T17:30:25.743Z
Made a feature request for escaping parts of cache for dynamic data. 
http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/7412950-exclude-cache-for-dynamic-data
Johannes Lamers
CC BY-SA 3.0
2015-04-10T09:15:40.557Z
Just saw this (I'm the dev for Shortlist) - right now the best option I've seen is to do as @carlcs did and escape the specific dynamic block. I've looked into alternatives and _right_ now, this seems the only way
Joel Bradbury
CC BY-SA 3.0
2015-04-01T17:03:22.877Z
2015-04-01T17:27:04.133Z
2015-04-01T17:27:04.133Z
carlcs
<p>How can I cache an entry, lets say a product card but exclude an dynamic part? Like amount of favorites / Or link to add or remove to favorite.</p>

<pre><code>{% set item = craft.shortlist.item(entry.id) %}

{% cache globally using key "product-card-" ~ entry.id until entry.dateUpdated %}

   ...

   {{ entry.title }}

   ...

   // EXCLUDE THIS PART FROM CACHE
   {% if item.inList %}
        &lt;a class="love animating fav" href="{{ item.removeActionUrl }}" data-id="{{ entry.id }}"&gt;&lt;i class="icon icon-heart"&gt;&lt;/i&gt;&lt;/a&gt;
    {% else %}
        &lt;a class="love animating" href="{{ item.addActionUrl }}" data-id="{{ entry.id }}"&gt;&lt;i class="icon icon-heart"&gt;&lt;/i&gt;&lt;/a&gt;
    {% endif %}

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

<p>In EE CE Cache there you had {exp:ce_cache:escape}. How can I do this in Craft?</p>

<p><strong>Made a feature request for escaping parts of cache for dynamic data.</strong></p>

<p><a href="http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/7412950-exclude-cache-for-dynamic-data" rel="nofollow">http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/7412950-exclude-cache-for-dynamic-data</a></p>

<p><strong>PLEASE VOTE :-)</strong></p>

<cache>
Cache entry but escape dynamic data
# Cache entry but escape dynamic data

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

How can I cache an entry, lets say a product card but exclude an dynamic part? Like amount of favorites / Or link to add or remove to favorite.
{% set item = craft.shortlist.item(entry.id) %}

{% cache globally using key "product-card-" ~ entry.id until entry.dateUpdated %}

   ...

   {{ entry.title }}

   ...

   // EXCLUDE THIS PART FROM CACHE
   {% if item.inList %}
        
    {% else %}
        
    {% endif %}

{% endcache %}

In EE CE Cache there you had {exp:ce_cache:escape}. How can I do this in Craft?
Made a feature request for escaping parts of cache for dynamic data.
http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/7412950-exclude-cache-for-dynamic-data
PLEASE VOTE :-)

**Tags:** cache


---

## 1 answers

### Answer by username_1 on 2015-04-01. Score: 2

You would simply not wrap it in cache tags. I don't think there's anything like that EE function to specifically exclude parts within the tag. Might be worth a feature request though?
{% set item = craft.shortlist.item(entry.id) %}

{% cache globally using key "product-card-" ~ entry.id ~ "-1" until entry.dateUpdated %}

    {{ entry.title }}

    ...

{% endcache %}

// EXCLUDE THIS PART FROM CACHE
{% if item.inList %}
    
{% else %}
    
{% endif %}

{% cache globally using key "product-card-" ~ entry.id ~ "-2" until entry.dateUpdated %}

    ...

{% endcache %}

> **Comments:**
> **username_0**: Doesn't work. It's repeating the cached content in the 2nd part.  
> **username_1**: Sorry, I overlooked that you're using custom keys. These need to be unique, so you have to add unique string to the key for each caching block.  
> **username_0**: Ok. that's what i was thinking. But you then end up with a lots of Cached content per entry. Let say you have some more dynamic data. All the cached content gets cluttered in the DB. I've posted a feature request to escape some parts of the cache tough.  
> **username_0**: Made a feature request for escaping parts of cache for dynamic data.  http://feedback.buildwithcraft.com/forums/285221-feature-requests/suggestions/7412950-exclude-cache-for-dynamic-data  
> **username_2**: Just saw this (I'm the dev for Shortlist) - right now the best option I've seen is to do as @username_1 did and escape the specific dynamic block. I've looked into alternatives and _right_ now, this seems the only way  

---

