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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions readthedocs/restapi/templates/restapi/footer.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% load cache %}

{# Vary the cache on the version #}

<!-- Inserted RTD Footer -->
<div class="injected">

Expand All @@ -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.

{% block versions %}
{% if translations %}
<dl>
Expand Down Expand Up @@ -57,6 +62,7 @@
</dl>
{% endif %}
{% endblock %}
{% endcache %}

{% block readthedocs %}
<dl>
Expand Down Expand Up @@ -136,3 +142,4 @@
{% endif %}

</div>