cache webpack_static helper to reduce json loading/parsing

https://github.com/mozilla/sumo-project/issues/874
This commit is contained in:
Leo McArdle 2021-10-26 10:28:51 +01:00 коммит произвёл Leo McArdle
Родитель a582a1a9cd
Коммит b44a688d87
2 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -413,6 +413,10 @@ STATICFILES_FINDERS = (
STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"
WEBPACK_LRU_CACHE = 128
if DEV or TEST:
WEBPACK_LRU_CACHE = 0
# Paths that don't require a locale prefix.
SUPPORTED_NONLOCALES = (
"1",

Просмотреть файл

@ -3,6 +3,7 @@ import re
import sys
from contextlib import contextmanager
from datetime import datetime
from functools import lru_cache
from django.conf import settings
from django.contrib.sites.models import Site
@ -353,6 +354,7 @@ def check_for_spam_content(data):
return is_toll_free or is_nanp_number or has_links
@lru_cache(maxsize=settings.WEBPACK_LRU_CACHE)
def webpack_static(source_path):
"""
Get the URL for an asset processed by webpack.