Homepage content blocks cache#6235
Homepage content blocks cache#6235ivan-mr merged 12 commits intodecidim:developfrom armandfardeau:performance/homepage-content-blocks-cache
Conversation
| private | ||
|
|
||
| def perform_caching? | ||
| false |
There was a problem hiding this comment.
You can define cache_hash in the ViewModel, make it return nil by default, and change perform_caching? body to cache_hash.present? so that you skip required method 😄
There was a problem hiding this comment.
Yes thank you!
|
Hi @armandfardeau can you please fix the title and link the github issue 🙏 ? Thanks |
tramuntanal
left a comment
There was a problem hiding this comment.
Hi @armandfardeau good start! 👏
I've just left you a couple of questions so that we are aligned when you retake this PR
| private | ||
|
|
||
| def cache_hash | ||
| "decidim/content_blocks/hero/#{Digest::MD5.hexdigest(model.attributes.to_s)}/#{current_organization.cache_version}" |
There was a problem hiding this comment.
why don't use model.updated_at instead of hashing all the attributes?
shouldn't we take into account also the current locale?
There was a problem hiding this comment.
Definitely the locale is needed so we have a cached version for each one.
There was a problem hiding this comment.
why don't use
model.updated_atinstead of hashing all the attributes?
shouldn't we take into account also the current locale?
The model doesn't have an updated_at attribute in this case, nor a cache_version therefore it is needed to hash all attributes.
There was a problem hiding this comment.
definitely, I just added them
There was a problem hiding this comment.
why don't use model.updated_at instead of hashing all the attributes?
I thought exactly the same when reviewing this... @armandfardeau could you add your answer as a comment in the code 🙏 ?
There was a problem hiding this comment.
why don't use model.updated_at instead of hashing all the attributes?
I thought exactly the same when reviewing this... @armandfardeau could you add your answer as a comment in the code 🙏 ?
For sure.
| private | ||
|
|
||
| def cache_hash | ||
| "decidim/content_blocks/last_activity/#{Digest::MD5.hexdigest(valid_activities.map(&:updated_at).to_s)}" |
There was a problem hiding this comment.
same as with the preivous cell
There was a problem hiding this comment.
same as with the preivous cell
In this case, suppose that the number of valid activities increases to a large number, which means a long identification key for the cache system to find. With an MD5 hash, we make sure that the key will remain the same length.
|
I will be able to work on it on Monday, thanks for your feedbacks |
|
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. @carolromero & @andreslucena feel free to chime in. |
|
@andreslucena It's been a long time and I should have moved on this but I think we need to open the door to a standardised way of testing hash of cached items. This implementation is a modest proposal. |
|
@armandfardeau I love French, but do you mind translating your previous comment into English? I'm guessing you had a rough day and it just slipped 🙈 |
Damn what a messy day! thanks |
ivan-mr
left a comment
There was a problem hiding this comment.
Everything seems ok. Thanks @armandfardeau !
|
There's an internal error in the repository. As soon as we solve it I will merge this PR. |
That Segfault looks like a nightmare, good luck |
|
The segfault is now fixed in develop branch. Can you merge it with your branch to solve it @armandfardeau , please? Thanks! |
|
@armandfardeau there's something funky with the cache and the tests! |
Thanks, I forgot to get back to English after switching locale, silly me. However, there are some issues on Meetings and Admin (I suspect a drop in performance) |
|
@ivan-mr Is the error I encounter a known flaky? |
The meeting test failure seems to be a flaky but the error on Admin you say, I don't see any error on it. |
ivan-mr
left a comment
There was a problem hiding this comment.
Looks great. Thanks @armandfardeau !
🎩 What? Why?
Add cache to homepage content blocks
This P.R. is an implementation proposal for a caching and hash testing strategy.
📌 Related Issues
📋 Subtasks