From 8de8a1fdefeb10feb3f69d59bd3838e9462cf256 Mon Sep 17 00:00:00 2001 From: Jose Alberto Hernandez Date: Tue, 17 Jun 2025 14:10:07 -0500 Subject: [PATCH] HTTP Cache service using environment variable --- README.md | 3 ++- env.sample | 3 +++ src/app/core/http/cache.interceptor.ts | 3 ++- .../loan-product-settings-step.component.html | 1 - src/assets/env.template.js | 3 +++ src/environments/environment.prod.ts | 1 + src/environments/environment.ts | 1 + 7 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4da9028c7..e4e33adc8 100644 --- a/README.md +++ b/README.md @@ -179,7 +179,8 @@ Available languages: | MIFOS_DEFAULT_CHAR_DELIMITER | Character delimiter for CSV exports | , | | MIFOS_WAIT_TIME_FOR_NOTIFICATIONS | Wait time in seconds for reading notifications | 60 | | MIFOS_WAIT_TIME_FOR_CATCHUP | Wait time in seconds for reading COB Catch-Up status | 30 | -| MIFOS_MIN_PASSWORD_LENGTH | WMinimum length for user passwords | 12 | +| MIFOS_MIN_PASSWORD_LENGTH | Minimum length for user passwords | 12 | +| MIFOS_HTTP_CACHE_ENABLED | whether to use HTTP Get calls with cache | false | #### UI Display Settings diff --git a/env.sample b/env.sample index 9be37b868..82e71000e 100644 --- a/env.sample +++ b/env.sample @@ -29,3 +29,6 @@ MIFOS_OAUTH_SERVER_URL=https://{$URL_OAUTH_SERVER} #Set the application client id, only used while Oauth is enabled MIFOS_OAUTH_CLIENT_ID=web-app + +#Enable or Disable HTTP Cache +MIFOS_HTTP_CACHE_ENABLED=true diff --git a/src/app/core/http/cache.interceptor.ts b/src/app/core/http/cache.interceptor.ts index e7f53f101..8f60c0372 100644 --- a/src/app/core/http/cache.interceptor.ts +++ b/src/app/core/http/cache.interceptor.ts @@ -7,6 +7,7 @@ import { Observable, Subscriber } from 'rxjs'; /** Custom Services */ import { HttpCacheService } from './http-cache.service'; +import { environment } from 'environments/environment'; /** * Caches HTTP requests. @@ -45,7 +46,7 @@ export class CacheInterceptor implements HttpInterceptor { } else { next.handle(request).subscribe( (event) => { - if (event instanceof HttpResponse) { + if (environment.httpCacheEnabled && event instanceof HttpResponse) { this.httpCacheService.setCacheData(request.urlWithParams, event); } subscriber.next(event); diff --git a/src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html b/src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html index 2561ae4a4..5e4752302 100644 --- a/src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html +++ b/src/app/products/loan-products/loan-product-stepper/loan-product-settings-step/loan-product-settings-step.component.html @@ -252,7 +252,6 @@