improve cache control support for /wire, /keys and legal

This commit is contained in:
Christian Grothoff 2022-05-16 11:56:10 +02:00
parent fac01f140f
commit 3db8f0f22d
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC
3 changed files with 33 additions and 1 deletions

View File

@ -1703,6 +1703,16 @@ setup_general_response_headers (struct TEH_KeyStateHandle *ksh,
= GNUNET_TIME_timestamp_min (m,
ksh->signature_expires);
}
/* Set cache control headers: our response varies depending on these headers */
GNUNET_break (MHD_YES ==
MHD_add_response_header (response,
MHD_HTTP_HEADER_VARY,
MHD_HTTP_HEADER_ACCEPT_ENCODING));
/* Information is always public, revalidate after 1 hour */
GNUNET_break (MHD_YES ==
MHD_add_response_header (response,
MHD_HTTP_HEADER_CACHE_CONTROL,
"public,max-age=3600"));
return GNUNET_OK;
}

View File

@ -483,6 +483,17 @@ build_wire_state (void)
wsh->dat));
}
TALER_MHD_add_global_headers (wsh->wire_reply);
/* Set cache control headers: our response varies depending on these headers */
GNUNET_break (MHD_YES ==
MHD_add_response_header (wsh->wire_reply,
MHD_HTTP_HEADER_VARY,
MHD_HTTP_HEADER_ACCEPT_ENCODING));
/* Information is always public, revalidate after 1 day */
GNUNET_break (MHD_YES ==
MHD_add_response_header (wsh->wire_reply,
MHD_HTTP_HEADER_CACHE_CONTROL,
"public,max-age=86400"));
{
struct GNUNET_HashCode h;
char etag[sizeof (h) * 2];

View File

@ -306,7 +306,18 @@ TALER_MHD_reply_legal (struct MHD_Connection *conn,
MHD_add_response_header (resp,
MHD_HTTP_HEADER_EXPIRES,
dat));
/* Set cache control headers: our response varies depending on these headers */
GNUNET_break (MHD_YES ==
MHD_add_response_header (resp,
MHD_HTTP_HEADER_VARY,
MHD_HTTP_HEADER_ACCEPT_LANGUAGE ","
MHD_HTTP_HEADER_ACCEPT ","
MHD_HTTP_HEADER_ACCEPT_ENCODING));
/* Information is always public, revalidate after 10 days */
GNUNET_break (MHD_YES ==
MHD_add_response_header (resp,
MHD_HTTP_HEADER_CACHE_CONTROL,
"public max-age=864000"));
if (NULL != legal)
GNUNET_break (MHD_YES ==
MHD_add_response_header (resp,