Skip to content

Commit 0e8187d

Browse files
Merge pull request #182 from springload/fix/cache
Make cache lifetime and invalidation work properly together
2 parents 6031192 + 0528037 commit 0e8187d

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed
Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import django_cache_url
2-
31
from madewithwagtail.settings import ENVIRONMENT, PROJECT # , CACHE_URL
42

3+
54
__all__ = [
65
"CACHES",
7-
"CACHALOT_TIMEOUT",
8-
"WAGTAILFRONTENDCACHE",
96
] # don't import DEV_CACHES by default
107

118
# Dont use redis because we don't need it
@@ -26,17 +23,3 @@
2623

2724
# Add a prefix to distinguish huey entries and app entries
2825
CACHES.get("default").update({"PREFIX": "-".join([PROJECT, ENVIRONMENT])})
29-
30-
# When this isn't set, it will eventually fill up redis
31-
CACHALOT_TIMEOUT = 300
32-
33-
# For frontend cache module
34-
WAGTAILFRONTENDCACHE = {
35-
"cloudfront": {
36-
"BACKEND": "wagtail.contrib.frontend_cache.backends.CloudfrontBackend",
37-
"DISTRIBUTION_ID": {
38-
# TODO change this when do the DNS changeover to madewithwagtail.org
39-
"madewithwagtail-preview-media.s3-website-ap-southeast-2.amazonaws.com": "E19LUSH371PZQA",
40-
},
41-
}
42-
}

madewithwagtail/settings/hosting.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
from .grains.logging import LOGGING
55
from .grains.sentry import *
66

7+
from typed_environment_configuration import StringVariable
8+
9+
AWS_CONTENT_DISTRIBUTION_ID = StringVariable(
10+
"AWS_CONTENT_DISTRIBUTION_ID", default=""
11+
).getenv()
12+
713
# Google Analytics settings
814
GOOGLE_TAG_MANAGER = False
915

@@ -31,11 +37,19 @@
3137
TASKS_RETRY_DELAY = 5 * 60 # 5 minutes delay
3238

3339

34-
CACHE_MIDDLEWARE_SECONDS = 86400 # 24 hours
35-
CACHE_TEMPLATE_FRAGMENTS_SECONDS = 86400 # 24 hours
40+
CACHE_MIDDLEWARE_SECONDS = 600
41+
CACHE_TEMPLATE_FRAGMENTS_SECONDS = 600
3642

3743
# Make sure we include the needed Middleware apps
3844
# Excluding logged in (admin) requests
3945
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
4046

4147
SECURE_HSTS_SECONDS = 31536000
48+
49+
# For frontend cache module
50+
WAGTAILFRONTENDCACHE = {
51+
"cloudfront": {
52+
"BACKEND": "wagtail.contrib.frontend_cache.backends.CloudfrontBackend",
53+
"DISTRIBUTION_ID": AWS_CONTENT_DISTRIBUTION_ID,
54+
}
55+
}

0 commit comments

Comments
 (0)