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

Cache contributors views #3091

Merged
merged 3 commits into from
Feb 12, 2024
Merged

Conversation

mathjazz
Copy link
Collaborator

@mathjazz mathjazz commented Feb 9, 2024

This patch caches all Contributors views for a period of 1 day:

  • /contributors
  • /LOCALE/contributors
  • /projects/PROJECT/contributors
  • /PROJECT/LOCALE/contributors

It mostly fixes #3082, but I'll keep the issue open until I check if there's something we can do to speed up the Authors and Time Range filters.

If this works well, we should cache the Insights views.

The patch is deployed to stage.

@mathjazz mathjazz requested a review from eemeli February 9, 2024 20:10
@@ -1,7 +1,10 @@
from django.urls import path, register_converter
from django.urls.converters import StringConverter
from django.views.decorators.cache import cache_page
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Django docs recommend to specify the per-view cache in the URLconf rather than next to the view functions themselves.

@@ -70,7 +73,9 @@
# Team contributors
path(
"contributors/",
Copy link
Collaborator Author

@mathjazz mathjazz Feb 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the docs, if multiple URLs point at the same view, each URL will be cached separately.

In this example, /de/contributors/ and /it/contributors/ will be cached separately, as you may expect. But once a particular URL has been requested, subsequent requests to that URL will use the cache.

Copy link
Member

@eemeli eemeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty straight-forward. My only (very minor) quibble is over the "per view" part of the PER_VIEW_CACHE_TIMEOUT variable, which is ultimately clear in context, but I was initially parsing it as something like "per user visit", which wouldn't really make sense.

@mathjazz
Copy link
Collaborator Author

Renamed PER_VIEW_CACHE_TIMEOUT to VIEW_CACHE_TIMEOUT.

@mathjazz mathjazz merged commit 2606255 into mozilla:main Feb 12, 2024
4 checks passed
@mathjazz mathjazz deleted the 3082-cache-contributors-page branch February 12, 2024 17:01
This was referenced Feb 12, 2024
ayanaar pushed a commit to ayanaar/pontoon that referenced this pull request Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache pontoon.contributors.views:ContributorsView.get view
2 participants