website/website/utils/context_processors.py
Jake Howard ee4914324c
Cache fragments for 6 hours
They really shouldn't change often
2022-10-04 21:27:53 +01:00

13 lines
441 B
Python

from django.conf import settings
from django.http.request import HttpRequest
def global_vars(request: HttpRequest) -> dict:
# noop caching in preview
fragment_cache_ttl = 0 if getattr(request, "is_preview", False) else 21600
return {
"SEO_INDEX": settings.SEO_INDEX,
"DEBUG": settings.DEBUG,
"FRAGMENT_CACHE_TTL": fragment_cache_ttl,
"FRAGMENT_CACHE_TTL_JITTER": fragment_cache_ttl * 0.1,
}