Skip to content

Commit fe57d73

Browse files
Demonstrate template level caching. Fix #545 (#561)
Co-authored-by: Thibaud Colas <[email protected]>
1 parent 067b8e2 commit fe57d73

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ __pycache__
2020
.vagrant/
2121
/.vagrant/
2222
/Vagrantfile.local
23+
/bakerydemo/cache
2324
!.gitignore
2425
bakerydemo/collect_static

bakerydemo/templates/blog/blog_index_page.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "base.html" %}
2-
{% load wagtailcore_tags navigation_tags wagtailimages_tags %}
2+
{% load wagtailcore_tags navigation_tags wagtailimages_tags wagtail_cache %}
33

44
{% if tag %}
55
{% block title %}
@@ -37,9 +37,11 @@ <h1 class="index-header__title">Blog</h1>
3737

3838
<div class="blog-list">
3939
{% if posts %}
40-
{% for blog in posts %}
41-
{% include "includes/card/blog-listing-card.html" %}
42-
{% endfor %}
40+
{% wagtailcache 500 posts %}
41+
{% for blog in posts %}
42+
{% include "includes/card/blog-listing-card.html" %}
43+
{% endfor %}
44+
{% endwagtailcache %}
4345
{% else %}
4446
<div class="col-md-12">
4547
<p>Oh, snap. Looks like we were too busy baking to write any blog posts. Sorry.</p>

0 commit comments

Comments
 (0)