Skip to content

Commit

Permalink
fix: Added language to page cache key (#7354)
Browse files Browse the repository at this point in the history
  • Loading branch information
marksweb committed Jul 3, 2022
1 parent c1290c9 commit d5a9f49
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ unreleased
* Fix except block using list instead of tuple. (#7334)
* Added cache ttl extension point.
* Added spell checking to pre-commit and github workflows
* Added current language to the page cache key (#6607)

3.10.1 (2022-06-28)
===================
Expand Down
4 changes: 2 additions & 2 deletions cms/cache/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@


def _site_cache_key(lang):
return "%s-%s" %(get_cms_setting('SITE_CHOICES_CACHE_KEY'), lang)
return "%s-%s" % (get_cms_setting('SITE_CHOICES_CACHE_KEY'), lang)


def _page_cache_key(lang):
return "%s-%s" %(get_cms_setting('PAGE_CHOICES_CACHE_KEY'), lang)
return "%s-%s" % (get_cms_setting('PAGE_CHOICES_CACHE_KEY'), lang)


def _clean_many(prefix):
Expand Down
9 changes: 5 additions & 4 deletions cms/cache/page.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

import hashlib
from datetime import timedelta
from importlib import import_module

from django.conf import settings
from django.utils import translation
from django.utils.cache import (
add_never_cache_headers, patch_response_headers, patch_vary_headers,
)
Expand All @@ -19,11 +19,12 @@


def _page_cache_key(request):
#sha1 key of current path
cache_key = "%s:%d:%s" % (
# sha1 key of current path
cache_key = "%s:%d:%s:%s" % (
get_cms_setting("CACHE_PREFIX"),
settings.SITE_ID,
hashlib.sha1(iri_to_uri(request.get_full_path()).encode('utf-8')).hexdigest()
hashlib.sha1(iri_to_uri(request.get_full_path()).encode('utf-8')).hexdigest(),
translation.get_language()
)
if settings.USE_TZ:
cache_key += '.%s' % get_timezone_name()
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ skip = *.js,*.po,./node_modules/*,./.idea/*,./docs/env/*,./docs/build/*,./.env/*

[options]
install_requires =
Django>=2.2,<4.0
Django>=2.2,<5.0
python_requires = >=3.7

0 comments on commit d5a9f49

Please sign in to comment.