From e543e0538f750ad6eef2de04fa8bdb71404fdd26 Mon Sep 17 00:00:00 2001 From: Ambroise Maupate Date: Tue, 8 Feb 2022 12:31:24 +0100 Subject: [PATCH] feat: Env var HTTP_CACHE_SHARED_MAX_AGE --- .env | 4 ++++ config/packages/api_platform.yaml | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/.env b/.env index 517d3f05..17f1c5d7 100644 --- a/.env +++ b/.env @@ -11,6 +11,10 @@ APP_UNSPLASH_CLIENT_ID= APP_TIMEZONE=Europe/Paris USER_UID=1000 +VARNISH_URL=http://varnish +HTTP_CACHE_MAX_AGE=60 +HTTP_CACHE_SHARED_MAX_AGE=600 + OPEN_ID_DISCOVERY_URL=https://accounts.google.com/.well-known/openid-configuration OPEN_ID_HOSTED_DOMAIN= OPEN_ID_CLIENT_ID= diff --git a/config/packages/api_platform.yaml b/config/packages/api_platform.yaml index cdd04219..b57ae5fd 100644 --- a/config/packages/api_platform.yaml +++ b/config/packages/api_platform.yaml @@ -19,3 +19,22 @@ api_platform: client_items_per_page: true items_per_page_parameter_name: itemsPerPage + http_cache: + # Automatically generate etags for API responses. + etag: true + public: true + # Default value for the response max age. + max_age: '%env(int:HTTP_CACHE_MAX_AGE)%' + # Default value for the response shared (proxy) max age. + shared_max_age: '%env(int:HTTP_CACHE_SHARED_MAX_AGE)%' + # Default values of the "Vary" HTTP header. + vary: [ 'Accept', 'Authorization', 'Origin', 'Accept-Encoding', 'Content-Type' ] + invalidation: + enabled: true + varnish_urls: [ '%env(VARNISH_URL)%' ] + defaults: + cache_headers: + public: true + max_age: '%env(int:HTTP_CACHE_MAX_AGE)%' + shared_max_age: '%env(int:HTTP_CACHE_SHARED_MAX_AGE)%' + vary: [ 'Accept', 'Authorization', 'Origin', 'Accept-Encoding', 'Content-Type' ]