Skip to content

Commit

Permalink
fix(configuration): enable cache only on prod env
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweak committed Sep 12, 2023
1 parent 7ede32f commit 6f0fb64
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
18 changes: 11 additions & 7 deletions api/config/packages/api_platform.yaml
Expand Up @@ -3,18 +3,22 @@ api_platform:
version: 1.0.0
# Mercure integration, remove if unwanted
mercure: ~
http_cache:
public: true
invalidation:
enabled: true
purger: 'api_platform.http_cache.purger.souin'
urls: ['%env(SOUIN_API_URL)%']
# Good defaults for REST APIs
defaults:
stateless: true
cache_headers:
max_age: 0
shared_max_age: 3600
vary: ['Content-Type', 'Authorization', 'Origin']
extra_properties:
standard_put: true

when@prod:
defaults:
cache_headers:
shared_max_age: 3600
http_cache:
public: true
invalidation:
enabled: true
purger: 'api_platform.http_cache.purger.souin'
urls: ['%env(SOUIN_API_URL)%']
12 changes: 6 additions & 6 deletions docker-compose.prod.yml
Expand Up @@ -23,12 +23,12 @@ services:
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET}
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET}
CADDY_GLOBAL_OPTIONS: |
order cache before rewrite
cache {
api {
souin
}
}
order cache before rewrite
cache {
api {
souin
}
}
database:
environment:
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.yml
Expand Up @@ -37,12 +37,12 @@ services:
MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}
CADDY_GLOBAL_OPTIONS: |
order cache before rewrite
cache {
api {
souin
}
}
order cache before rewrite
cache {
api {
souin
}
}
restart: unless-stopped
volumes:
- php_socket:/var/run/php
Expand Down

0 comments on commit 6f0fb64

Please sign in to comment.