Categorygithub.com/ONSdigital/dp-legacy-cache-proxy
modulepackage
1.7.0
Repository: https://github.com/onsdigital/dp-legacy-cache-proxy.git
Documentation: pkg.go.dev

# README

dp-legacy-cache-proxy

The proxy handles the cache headers for pages within the legacy CMS and sits between the Frontend Router and Babbage.

It receives requests from dp-frontend-router and redirects them to Babbage - returning the response with the correct Cache-Control header.

All the requests that users make to Babbage (or any other services that rely on the Legacy Cache API for caching purposes, like the Release Calendar) will go through this Proxy first. When Babbage sends the response back to the user, this Proxy will intercept it and decide whether it needs to set the max-age/s-maxage/stale-while-revalidate directives in the Cache-Control header to appropriate values.

Getting started

Dependencies

  • No further dependencies other than those defined in go.mod

Configuration

Environment variableDefaultDescription
BIND_ADDR:29200The host and port to bind to
GRACEFUL_SHUTDOWN_TIMEOUT5sThe graceful shutdown timeout1
HEALTHCHECK_INTERVAL30sTime between self-healthchecks1
HEALTHCHECK_CRITICAL_TIMEOUT90sTime duration1 to wait until an unhealthy dependent propagates its state to make this app unhealthy
OTEL_BATCH_TIMEOUT5sTime duration1 after which a batch will be sent regardless of size
OTEL_EXPORTER_OTLP_ENDPOINTlocalhost:4317OpenTelemetry Exporter address
OTEL_SERVICE_NAMEdp-legacy-cache-proxyThe name of this service in OpenTelemetry
OTEL_ENABLEDfalseTurn OTEL on / off
BABBAGE_URLhttp://localhost:8080Babbage address, where most of the incoming requests are forwarded to
LEGACY_CACHE_API_URLhttp://localhost:29100Legacy Cache API address
RELEASE_CALENDAR_URLhttp://localhost:27700Release calendar frontend controller address
CACHE_TIME_DEFAULT15mDefault value1 for max-age2
CACHE_TIME_ERRORED30sErrored value1 for max-age2
CACHE_TIME_LONG4hLong value1 for max-age2
CACHE_TIME_SHORT10sShort value1 for max-age2
ENABLE_PUBLISH_EXPIRY_OFFSETfalseDetermines if publish expiry offset is used which enables a shorter cache time for recently published content
PUBLISH_EXPIRY_OFFSET3mPeriod of time1 after a release in which the proxy needs to return a short value for max-age 2
READ_TIMEOUT15sMaximum time1 the server will wait for a client to send a complete request
WRITE_TIMEOUT30sMaximum time1 the server will wait while trying to write a response to the client
STALE_WHILE_REVALIDATE_SECONDS-1If non-negative, add the stale-while-revalidate option (using this number as the seconds value) to any Cache-control header responses
ENABLE_MAX_AGE_COUNTDOWNtrueDuring the countdown to a release time: if this is true, max-age value will countdown; if false, max-age=0 is used
ENABLE_SEARCH_CONTROLLERfalseEnable routing to search controller
SEARCH_CONTROLLER_URLhttp://localhost:25000Search controller address, where previousreleases and relateddata requests are forwarded to

Auto-Deployment of secrets

Functionality has been added to the nomad plan so that when the secrets are deployed to Vault, this will automatically cause Nomad to trigger a redeployment of the application to pick up the new secrets. :warning: Please note that this functionality does not appear to work with the current nomad/vault versions, but if these are upgraded it may then become functional.

Contributing

See CONTRIBUTING for details.

License

Copyright © 2024, Office for National Statistics https://www.ons.gov.uk

Released under MIT license, see LICENSE for details.

Footnotes

  1. using golang's time.Duration format 2 3 4 5 6 7 8 9 10 11

  2. a directive of the Cache-Control header 2 3 4 5

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

BuildTime represents the time in which the service was built.
GitCommit represents the commit (SHA-1) hash of the service that is running.
Version represents the version of the service that is running.