diff options
author | Christian Grothoff <christian@grothoff.org> | 2024-04-07 19:40:56 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2024-04-07 19:41:01 +0200 |
commit | b161b36af2f2f68bc8155dd0f97977100f6e3148 (patch) | |
tree | 599b375a7205cbd2a036c72aa53dfe2c59332549 | |
parent | 0ddab477708740ac1f930e68c0f24ab76dde7a3e (diff) |
add cache control to /config; eliminate cache expiration distinguisher from /keys
-rw-r--r-- | src/exchange/taler-exchange-httpd_config.c | 24 | ||||
-rw-r--r-- | src/exchange/taler-exchange-httpd_keys.c | 6 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/exchange/taler-exchange-httpd_config.c b/src/exchange/taler-exchange-httpd_config.c index 29cbf2b51..fc470b1b5 100644 --- a/src/exchange/taler-exchange-httpd_config.c +++ b/src/exchange/taler-exchange-httpd_config.c @@ -36,6 +36,21 @@ TEH_handler_config (struct TEH_RequestContext *rc, if (NULL == resp) { + struct GNUNET_TIME_Absolute a; + struct GNUNET_TIME_Timestamp km; + char dat[128]; + + a = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_DAYS); + /* Round up to next full day to ensure the expiration + time does not become a fingerprint! */ + a = GNUNET_TIME_absolute_round_down (a, + GNUNET_TIME_UNIT_DAYS); + a = GNUNET_TIME_absolute_add (a, + GNUNET_TIME_UNIT_DAYS); + /* => /config response stays at most 48h in caches! */ + km = GNUNET_TIME_absolute_to_timestamp (a); + TALER_MHD_get_date_string (km.abs_time, + dat); resp = TALER_MHD_MAKE_JSON_PACK ( GNUNET_JSON_pack_array_steal ("supported_kyc_requirements", TALER_KYCLOGIC_get_satisfiable ()), @@ -50,6 +65,15 @@ TEH_handler_config (struct TEH_RequestContext *rc, "urn:net:taler:specs:exchange:c-reference"), GNUNET_JSON_pack_string ("version", EXCHANGE_PROTOCOL_VERSION)); + + GNUNET_break (MHD_YES == + MHD_add_response_header (resp, + MHD_HTTP_HEADER_EXPIRES, + dat)); + GNUNET_break (MHD_YES == + MHD_add_response_header (resp, + MHD_HTTP_HEADER_CACHE_CONTROL, + "public,max-age=21600")); /* 6h */ } return MHD_queue_response (rc->connection, MHD_HTTP_OK, diff --git a/src/exchange/taler-exchange-httpd_keys.c b/src/exchange/taler-exchange-httpd_keys.c index 05fb685e0..f49a00612 100644 --- a/src/exchange/taler-exchange-httpd_keys.c +++ b/src/exchange/taler-exchange-httpd_keys.c @@ -2290,6 +2290,12 @@ setup_general_response_headers (void *cls, r = GNUNET_TIME_relative_min (TEH_max_keys_caching, ksh->rekey_frequency); a = GNUNET_TIME_relative_to_absolute (r); + /* Round up to next full day to ensure the expiration + time does not become a fingerprint! */ + a = GNUNET_TIME_absolute_round_down (a, + GNUNET_TIME_UNIT_DAYS); + a = GNUNET_TIME_absolute_add (a, + GNUNET_TIME_UNIT_DAYS); km = GNUNET_TIME_absolute_to_timestamp (a); we = GNUNET_TIME_absolute_to_timestamp (wire_state->cache_expiration); m = GNUNET_TIME_timestamp_min (we, |