Django / Production

Fare un passo 24 Di 24

Webhook e cache

Utilizza la cache di Django per velocizzare la lettura locale delle traduzioni ed esponi un webhook firmato per gli aggiornamenti di Altified.

Per l'ambiente di produzione, configura una cache Django condivisa come Redis in modo che tutti i web worker leggano le stesse traduzioni.

settings.py
CACHES = { "default": { "BACKEND": "django.core.cache.backends.redis.RedisCache", "LOCATION": "redis://127.0.0.1:6379", } }

Esporre l'endpoint webhook dell'SDK se si desidera che Altified invii le traduzioni completate nella cache dell'applicazione.

urls.py
from django.urls import include, path urlpatterns = [ ..., path("altified/", include("django_altified.urls")), ]
  • The webhook URL is /altified/webhook/.
  • Altified signs webhook bodies with HMAC-SHA256 using the existing ALTIFIED_API_KEY.
  • The SDK stores valid webhook translations in Django cache.
  • Local memory cache is fine for development but not enough for multi-worker production.

Intestazione della firma

Le richieste Webhook devono includere X-Altified-Signature: sha256=<digest>La chiave API non elaborata non viene mai inviata come token webhook.