home: Add rel=dns-prefetch to Gravatar and any Zulip avatar host.

This hints to the browser that it should start DNS lookups for the
host, since it is likely to be necessary.  It is a softer form than
`rel-preconnect`, which may be unnecessary in these cases, if the
client has the resources cached already.
This commit is contained in:
Alex Vandiver 2024-08-02 18:48:42 +00:00 committed by Tim Abbott
parent 00dfb60f5b
commit 854ec40def
2 changed files with 8 additions and 0 deletions

View File

@ -8,6 +8,10 @@
{% endblock %}
{% block customhead %}
{% if enable_gravatar %}<link rel="dns-prefetch" href="https://secure.gravatar.com" />
{% endif -%}
{% if s3_avatar_public_url_prefix %}<link rel="dns-prefetch" href="{{ s3_avatar_public_url_prefix }}" />
{% endif -%}
<meta name="apple-mobile-web-app-capable" content="yes" />
<link href="{{ static('images/logo/apple-touch-icon-precomposed.png') }}" rel="apple-touch-icon-precomposed" />
<style>

View File

@ -241,6 +241,10 @@ def home_real(request: HttpRequest) -> HttpResponse:
"page_params": page_params,
"csp_nonce": csp_nonce,
"color_scheme": user_permission_info.color_scheme,
"enable_gravatar": settings.ENABLE_GRAVATAR,
"s3_avatar_public_url_prefix": settings.S3_AVATAR_PUBLIC_URL_PREFIX
if settings.LOCAL_UPLOADS_DIR is None
else "",
},
)
patch_cache_control(response, no_cache=True, no_store=True, must_revalidate=True)