gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated: try to fix #7245 via cache contr


From: gnunet
Subject: [taler-merchant] branch master updated: try to fix #7245 via cache control
Date: Mon, 06 Jun 2022 14:31:51 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 2d1e2b3e try to fix #7245 via cache control
2d1e2b3e is described below

commit 2d1e2b3e9992652ab1ff2e7b8a34a511779d04dd
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Jun 6 14:31:46 2022 +0200

    try to fix #7245 via cache control
---
 ...r-merchant-httpd_private-get-instances-ID-kyc.c | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c 
b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
index e0e2cd39..fbb4f63f 100644
--- a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
+++ b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
@@ -35,6 +35,18 @@
  */
 #define STALE_KYC_TIMEOUT GNUNET_TIME_UNIT_MONTHS
 
+/**
+ * How long should clients cache a KYC failure response?
+ */
+#define EXPIRATION_KYC_FAILURE GNUNET_TIME_relative_multiply ( \
+    GNUNET_TIME_UNIT_MINUTES, 5)
+
+/**
+ * How long should clients cache a KYC success response?
+ */
+#define EXPIRATION_KYC_SUCCESS GNUNET_TIME_relative_multiply ( \
+    GNUNET_TIME_UNIT_HOURS, 1)
+
 
 /**
  * Information we keep per /kyc request.
@@ -303,8 +315,44 @@ resume_kyc_with_response (struct KycContext *kc,
                           unsigned int response_code,
                           struct MHD_Response *response)
 {
+  char dat[128];
+
   kc->response_code = response_code;
   kc->response = response;
+  switch (response_code)
+  {
+  case MHD_HTTP_OK:
+    /* KYC failed, cache briefly */
+    TALER_MHD_get_date_string (GNUNET_TIME_relative_to_absolute (
+                                 EXPIRATION_KYC_FAILURE),
+                               dat);
+    GNUNET_break (MHD_YES ==
+                  MHD_add_response_header (response,
+                                           MHD_HTTP_HEADER_EXPIRES,
+                                           dat));
+    GNUNET_break (MHD_YES ==
+                  MHD_add_response_header (response,
+                                           MHD_HTTP_HEADER_CACHE_CONTROL,
+                                           "max-age=300"));
+    break;
+  case MHD_HTTP_NO_CONTENT:
+    /* KYC passed, cache for a long time! */
+    TALER_MHD_get_date_string (GNUNET_TIME_relative_to_absolute (
+                                 EXPIRATION_KYC_SUCCESS),
+                               dat);
+    GNUNET_break (MHD_YES ==
+                  MHD_add_response_header (response,
+                                           MHD_HTTP_HEADER_EXPIRES,
+                                           dat));
+    GNUNET_break (MHD_YES ==
+                  MHD_add_response_header (response,
+                                           MHD_HTTP_HEADER_CACHE_CONTROL,
+                                           "max-age=3600"));
+    break;
+  case MHD_HTTP_BAD_GATEWAY:
+  case MHD_HTTP_GATEWAY_TIMEOUT:
+    break; /* no caching */
+  }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Resuming /kyc handling as exchange interaction is done (%u)\n",
               response_code);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]