Skip to content

Cache the footer_api template based on version for one minute #4524

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

Closed
wants to merge 3 commits into from

Conversation

ericholscher
Copy link
Member

@ericholscher ericholscher commented Aug 15, 2018

This is something that should increase the speed of our responses on the most popular versions.
It will make it so that users who update their versions might not see the footer change in under a minute,
but I think we can probably put up with that for the hopeful performance benefits.

I think that increasing this also makes a lot of sense, if we build a way to bust the cache. I think generating this fresh on every pageview for the most part doesn't make much sense.

This is something that should increase the speed of our responses on the most popular versions.
It will make it so that users who update their versions might not see the footer change in under a minute,
but I think we can probably put up with that for the hopeful performance benefits.
@ericholscher ericholscher requested a review from a team August 15, 2018 17:04
@ericholscher
Copy link
Member Author

This is mainly here for a fallback during the Azure migration, but I think it probably makes sense to push out before, if it makes sense. I mostly want to see what happens when we do it :)

ericholscher added a commit that referenced this pull request Aug 15, 2018
This is similar to #4524,
where resolving a ton of URL's for versions is time consuming.
This limits that by only listing the stable version,
 if it exists,
for featured projects on our homepage
{% load cache %}

{# Vary the cache on the version #}
{% cache 60 footer-html version.pk %}
Copy link
Member

Choose a reason for hiding this comment

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

What about adding versions.count as a key also here and increasing the time of the cache a little more?

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually realized this isn't specific to the version, but to the project as a whole, so that should be even better.

Copy link
Member Author

Choose a reason for hiding this comment

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

The VCS block actually will change by page, so I need to think through this a bit more.

@ericholscher
Copy link
Member Author

Need to think about this a bit more granularly. Currently we're linking to the specific page that a user hit, so caching this actually will not work 100%.

@ericholscher ericholscher added the PR: work in progress Pull request is not ready for full review label Aug 16, 2018
@agjohnson agjohnson added this to the Refactoring milestone Aug 27, 2018
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

I like the idea. I'm sure this will improve our API response in a good way.

Although, I'd like to think a little bit more about this and add more variables to the vary so we don't fail on caching.

Yesterday we had an issue with the cache on the frontpage 😄

@@ -11,6 +15,7 @@
<div class="rst-other-versions">
{% endif %}

{% cache 60 footer_html_versions project.pk %}
Copy link
Member

Choose a reason for hiding this comment

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

I think we should cache the sections "Versions" and "Languages" in different blocks. Adding/Removing a language won't invalidate the cache otherwise.

Also, why footer_html_version? Should be just versions the right variable to check? And, I think it should be versions.count at least

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, this wasn't caught on review of the front page, but whenever cache tag is used, we need to account for the user language as a separate argument as well. Without this, the language of the first user to cache this will be used.

@ericholscher
Copy link
Member Author

Closing this, as I don't think it's an issue we're currently facing, and had some issues.

@stsewd stsewd deleted the cache-footer-html branch November 1, 2018 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: work in progress Pull request is not ready for full review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants