Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page cache key doesn't depend on language #6607

Closed
sephii opened this issue Feb 2, 2019 · 4 comments
Closed

Page cache key doesn't depend on language #6607

sephii opened this issue Feb 2, 2019 · 4 comments

Comments

@sephii
Copy link
Contributor

sephii commented Feb 2, 2019

Summary

The docs for the CMS_PAGE_CACHE setting mention that the language is used to build the cache key:

Should the output of pages be cached? Takes the language, and time zone into account. Pages for logged in users are not cached. If the toolbar is visible the page is not cached as well.

The _page_cache_key function relies on request.get_full_path() to add the language to the cache key. However there are cases where the language is not in the path. For example you could create your own middleware that sets the language depending on the hostname, instead of the path (which is my case).

I think just adding translation.get_language() to the key would do the trick without any side effect.

Expected behaviour

The cache includes the current active language instead of relying of the language being in the URL.

Actual behaviour

The cache relies on the language being part of the URL.

Environment

  • Python version: N/A
  • Django version: 2.0
  • django CMS version: 3.6
@sephii sephii changed the title Page cache doesn't depend on language Page cache key doesn't depend on language Feb 2, 2019
@sephii
Copy link
Contributor Author

sephii commented Feb 2, 2019

I made a fix here. I'd be happy to submit it as a PR but I guess I should write a test first. I'll do it when I have more time.

@viktor-yunenko
Copy link

Hi @sephii, that sounds great, thank you! And sure please feel free to submit a PR 👍

@stale
Copy link

stale bot commented Jun 30, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jun 30, 2022
@marksweb marksweb self-assigned this Jul 1, 2022
@marksweb marksweb removed the stale label Jul 1, 2022
marksweb added a commit to marksweb/django-cms that referenced this issue Jul 1, 2022
@marksweb
Copy link
Sponsor Member

marksweb commented Jul 3, 2022

Resolved by #7354

@marksweb marksweb closed this as completed Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants