Skip to content

Instantly share code, notes, and snippets.

@ivangrozni
Created May 14, 2024 15:32
Show Gist options
  • Save ivangrozni/79011ff3f6d451b8521127385ac5b75f to your computer and use it in GitHub Desktop.
Save ivangrozni/79011ff3f6d451b8521127385ac5b75f to your computer and use it in GitHub Desktop.
http_cache_control--LDCL-55.patch
diff --git a/src/EventSubscriber/CacheControlEventSubscriber.php b/src/EventSubscriber/CacheControlEventSubscriber.php
index 89a627cc91fa1c889ac56f56ce597aea761ffb66..1606de60ef1ef229ef0f6accc415ca7dc3fa0742 100644
--- a/src/EventSubscriber/CacheControlEventSubscriber.php
+++ b/src/EventSubscriber/CacheControlEventSubscriber.php
@@ -69,10 +69,14 @@ class CacheControlEventSubscriber implements EventSubscriberInterface {
if ($ttl != $response->getMaxAge()) {
$response->setClientTtl($ttl);
- $response->setSharedMaxAge($ttl);
+ if (!$response->headers->hasCacheControlDirective('s-maxage')) {
+ $response->setSharedMaxAge($ttl);
+ }
}
elseif ($ttl = $config->get('cache.http.s_maxage')) {
- $response->setSharedMaxAge($ttl);
+ if (!$response->headers->hasCacheControlDirective('s-maxage')) {
+ $response->setSharedMaxAge($ttl);
+ }
}
if ($response->getStatusCode() >= 500) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment