-
Notifications
You must be signed in to change notification settings - Fork 3
add caching to remaining views #1555
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
Conversation
mbertrand
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just one comment about caching of the featured resources view (check with Ferdi about that one).
Also, the news_events/views/FeedItemViewSet and FeedSourceViewSet could use caching.
| .distinct() | ||
| ) | ||
|
|
||
| @method_decorator( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was some deliberate results randomization added to this featured list view so as not to give any apparent preference to any particular unit. Might be good to double-check with Ferdi to see if it's okay if that randomization is cached so all anonymous users see the same result for 24 hours before it's randomized again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double checked with ferdi. He said we can leave this as-is and have a separate ticket to handle the randomization on the frontend.
|
PS and clear the cache after news_events tasks or mgmt command are run |
mbertrand
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 👍
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/5450
Description (What does it do?)
This PR adds caching to the remaining server side views. We cache for all users on views that don't have any user specific info using "cache_page_for_all_users" decorator otherwise we use "cache_page_for_anonymous_users" to only cache for anonymous users
How can this be tested?
there are some further instructions (specific to search cache but can now be applied to remaining api views) here
Additional Context
Some key things in this PR for reviewer to double check:
The cache is by default now set to the "DummyCache" - we can explicitly enable and disable on a per test basis if the point of the test is to test something with caching enabled as done here