<p>In short, it's worth caching anything that is at all time expensive, really.  </p>

<p>It's always going to be significantly quicker to retrieve a cached chunk from the DB by key versus parsing a template section - and especially so a complex one with many related elements being pulled in.</p>

<p>However, if those are live products, i.e. with add to cart forms, you'll need to make sure the forms remain valid (think about current CSRF token, etc - you can insert these with JS on page load, for example) - and that your cache breaks whenever the cached thing is updated (which should mostly be automatic).</p>

<p>Note that once you start caching a lot of different things, it can take several seconds for all the stale cache chunks on complex pages to be deleted after you make changes in the control panel (you can see the little queue thing executing this after you save your updates) - so it will mean that your content changes will no longer be literally instant, and this can confuse if you're not aware of it happening.  In our case it can take up to a minute before it all washes through, so your content editors need to be aware of this.</p>

CC BY-SA 4.0
2019-09-26T07:53:11.860Z
Thanks Jeremy, super helpful.
James Greig
CC BY-SA 4.0
2019-09-26T03:59:10.537Z
2019-09-26T03:59:10.537Z
Jeremy Daalder
<p>So we have a Commerce project that shows lots of products per page/category as per any standard store.</p>

<p>Each product block comprises:  </p>

<ul>
<li>Product name</li>
<li>Product price</li>
<li>Brand (via category field) [eager loaded]</li>
<li>Image [eager loaded]</li>
</ul>

<p>Is it worth caching each of these blocks with a unique key?</p>

<craft3><plugin-craftcommerce><cache><performance>
Is it worth caching product blocks for use on a category page?
# Is it worth caching product blocks for use on a category page?

(Asked by: username_0 on 2019-09-25)

So we have a Commerce project that shows lots of products per page/category as per any standard store.

Each product block comprises:

* Product name
* Product price
* Brand (via category field) [eager loaded]
* Image [eager loaded]

Is it worth caching each of these blocks with a unique key?

**Tags:** craft3, plugin-craftcommerce, cache, performance

---

## 1 answers

### Answer by username_1 on 2019-09-26. Score: 3 | Accepted answer

In short, it's worth caching anything that is at all time expensive, really.

It's always going to be significantly quicker to retrieve a cached chunk from the DB by key versus parsing a template section - and especially so a complex one with many related elements being pulled in.

However, if those are live products, i.e. with add to cart forms, you'll need to make sure the forms remain valid (think about current CSRF token, etc - you can insert these with JS on page load, for example) - and that your cache breaks whenever the cached thing is updated (which should mostly be automatic).

Note that once you start caching a lot of different things, it can take several seconds for all the stale cache chunks on complex pages to be deleted after you make changes in the control panel (you can see the little queue thing executing this after you save your updates) - so it will mean that your content changes will no longer be literally instant, and this can confuse if you're not aware of it happening. In our case it can take up to a minute before it all washes through, so your content editors need to be aware of this.

> **Comments:**
> **username_0**: Thanks Jeremy, super helpful.  

---

