diff --git a/website/common/templates/common/listing-item.html b/website/common/templates/common/listing-item.html
index c986dff..df0c2fa 100644
--- a/website/common/templates/common/listing-item.html
+++ b/website/common/templates/common/listing-item.html
@@ -13,7 +13,7 @@
{% include "common/content-details.html" %}
- {% cache 900|jitter:60 "summary" page.id request.is_preview %}
+ {% cache FRAGMENT_CACHE_TTL|jitter:FRAGMENT_CACHE_TTL_JITTER "summary" page.id request.is_preview %}
{{ page.summary }}
{% endcache %}
diff --git a/website/common/wagtail_hooks.py b/website/common/wagtail_hooks.py
new file mode 100644
index 0000000..30df29e
--- /dev/null
+++ b/website/common/wagtail_hooks.py
@@ -0,0 +1,23 @@
+from django.core.cache import cache
+from django.core.cache.utils import make_template_fragment_key
+from django.http.request import HttpRequest
+from wagtail import hooks
+from wagtail.models import Page
+
+from website.common.models import BasePage
+
+FRAGMENT_CACHES = {"summary", "content-details"}
+
+
+@hooks.register("after_edit_page")
+def clear_fragment_cache(request: HttpRequest, page: Page) -> None:
+ if not isinstance(page, BasePage):
+ return
+
+ cache.delete_many(
+ [
+ # Empty string is for the empty value of `request.is_preview`
+ make_template_fragment_key(cache_name, [page.id, False])
+ for cache_name in FRAGMENT_CACHES
+ ]
+ )
diff --git a/website/utils/context_processors.py b/website/utils/context_processors.py
index fc7fa77..6f6099e 100644
--- a/website/utils/context_processors.py
+++ b/website/utils/context_processors.py
@@ -3,4 +3,11 @@ from django.http.request import HttpRequest
def global_vars(request: HttpRequest) -> dict:
- return {"SEO_INDEX": settings.SEO_INDEX, "DEBUG": settings.DEBUG}
+ # noop caching in preview
+ fragment_cache_ttl = 0 if getattr(request, "is_preview", False) else 3600
+ return {
+ "SEO_INDEX": settings.SEO_INDEX,
+ "DEBUG": settings.DEBUG,
+ "FRAGMENT_CACHE_TTL": fragment_cache_ttl,
+ "FRAGMENT_CACHE_TTL_JITTER": fragment_cache_ttl * 0.1,
+ }